Skip to content
Advertisement

Running awk command in remote host fails

I am running a shell script to run awk command on a remote host. The awk command runs fine locally, but when run for the remote host fails (the redirected file is empty):

Here is the script run on remote host:

JavaScript

smb.conf.tmp is empty in remote host !!

Locally:

JavaScript

I followed this link for awk running on remote host

Advertisement

Answer

The quoting mechanism you have chosen prevents the remote shell from seeing the locally defined variable IFM_MOUNT. Use double quotes instead to have the value interpolated into the string.

JavaScript

Notice how single quotes inside double quotes do not actually quote anything; and so any literal dollar sign needs to be escaped with a backslash.

(I was tempted to make a more substantial refactoring of your Awk script, but that would perhaps obscure the point.)

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement