Shell script with wget in ssh command

Hi,
I am using a linux with bash.
I have a script written which will login to a remote server and from there it runs a "wget" to downlaod a build file from a webserver.

Here is the line inside the script:
ssh -t -q -o StrictHostKeyChecking=no -o ConnectTimeout=5 root@${a[i]}'wget http://$ip/admBuilds/vADM_$build/RPMs/InSightUpdate-$rn.upd'

here ${a[i]} is the way to get the IPs from the array of IPs.
$ip is a IP of the server, $ build is the folder name and $rn is the filename.
But, when i run this script, i am not able to download this file on the remote server.

It simply doesnt execute this command.
I logged in on the remote machine where this command will be run and can see that the wget is infact available on the system.

I am not able to figure it out why it is failing when i pass this line from the shell script.

Any help appreciated.

Maybe you need to setup the environment more, like this

ssh him@there '. ./.profile ; wget whatever'
1 Like

There's a space missing:

...root@${a}'wget http://$ip/admBuilds/vADM_$build/RPMs/InSightUpdate-$rn.upd'
...root@${a} 'wget http://$ip/admBuilds/vADM_$build/RPMs/InSightUpdate-$rn.upd'
1 Like

You could ssh a tunnel and wget locally, assuming you cannot wget directly. You can even leave the ssh tunnels to all of them up on different adjacent local high ports, and just increment the port.

1 Like

Thanks a lot folks.
I figured it out what went wrong.
I was trying to extract the variable's value within single quotes ( ' )
'wget http://$ip/admBuilds/vADM_$build/RPMs/InSightUpdate-$rn.upd'
If you look at how wget is at work,you can notice that i am trying to use variables inside the single quoted line, which will not allow to get the value of the variables.

Thanks