Last part of script to remote host not working...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Last part of script to remote host not working...
# 1  
Old 07-26-2016
Last part of script to remote host not working...

Hi,

I got most of the script working, last part which does the ssh to remote and execute the command not working.


Code:
for SSH in ${HostList}; do
    echo ${SSH}
    echo ""
    SSH2SEND=ssh user@${SSH} curl -v $URL
    echo $SSH2SEND
done

error message I am getting       user@10.xx.xx.xx: command not found

# 2  
Old 07-26-2016
There's obviously a double quote missing.
# 3  
Old 07-26-2016
Quote:
Originally Posted by RudiC
There's obviously a double quote missing.
Thanks. I fix the double quote but now I get command not found.
# 4  
Old 07-26-2016
Quote the string
Code:
    SSH2SEND="ssh user@${SSH} curl -v $URL"

# 5  
Old 07-26-2016
Please DON'T modify posts that have been referred to by others pulling the rug from under them!

You need to use "command substitution" like
Code:
SSH2SEND=$(ssh user@${SSH} curl -v $URL)

# 6  
Old 07-26-2016
I added the quote back on. Now I don't get any error message but it doesn't do anything. it just prints this on the screen.

Code:
for SSH in ${HostList}; do
    echo ${SSH}
    echo ""
    SSH2SEND="ssh user@${SSH} curl -v $URL"
    echo $SSH2SEND
done


Here is the output...

Code:
ssh user@10.xx.xx.xx curl -v test.com
10.xx.xx.xx

ssh user@10.xx.xx.xx curl -v test.com
10.xx.xx.xx

ssh user@10.xx.xx.xx curl -v test.com
10.xx.xx.xx

ssh user@10.xx.xx.xx curl -v test.com
10.xx.xx.xx

ssh user@10.xx.xx.xx curl -v test.com
10.xx.xx.xx

ssh user@10.xx.xx.xx curl -v test.com

---------- Post updated at 02:24 PM ---------- Previous update was at 01:37 PM ----------

I think i am close but not 100%. I updated the script. now I get SSH error message.


Code:
line 69: (ssh: command not found
(ssh user@10.xx.xx.xx curl -v test.com)

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check/get the exit status of a remote command executed on remote host through script

Geeks, Could you please help me out in my script and identify the missing piece. I need to check/get the exit status of a remote command executed on remote host through script and send out an email when process/processes is/are not running on any/all server(s). Here's the complete... (5 Replies)
Discussion started by: lovesaikrishna
5 Replies

2. Shell Programming and Scripting

Run script on remote host

Hi friends, I have two servers. Server A and B. I want to run one script on server A by logging in to server B. Can anyone provide me code for this.? I tried it by using following ssh username@serverA ./script Then it prompt me the password. I give correct password of the server A. but it... (7 Replies)
Discussion started by: Nakul_sh
7 Replies

3. Shell Programming and Scripting

Pause processes in remote host and resume execution in another remote host

Hi, Given addresses of 2 remote machines, using a shell script is it possible to get the state of running processes in "src" stop all the processes in "src" exit out of "src" ssh into "dest" resume the state of executing processes captured in step 1 in "dest" Assumption: "src" is... (3 Replies)
Discussion started by: Saeya Darsan
3 Replies

4. Shell Programming and Scripting

manage an interactive script on a remote host

OS~AIX 6.1 I'm running an interactive shell script i.e.,waits for a user response a few times while executing, after doing ssh to a AIX server. I'm just wondering what options I have if the ssh connection to the server is lost while executing the script, do I have to run the script again, which in... (2 Replies)
Discussion started by: mbak
2 Replies

5. Shell Programming and Scripting

Plz help me using expect script for remote host

I am newbie in Unix and Expect script, so please help me :( I'm using expect script for remote another host: #!/usr/bin/expect -f set timeout 10 spawn ssh -l root 10.120.18.4 expect "password:" send "password\r" expect "@" interact And now how can i use expect script for access mysql... (2 Replies)
Discussion started by: wormym
2 Replies

6. UNIX for Dummies Questions & Answers

Run a script on remote host

Hi, I wish to run a script located on a remote host machineB from machineA. I am using ssh and running the below on machineA. However, the ssh does not seem to work and freezes at ssh -l wlsadmin machineB -v Sun_SSH_1.1.2, SSH protocols 1.5/2.0, OpenSSL 0x0090704f debug1: Reading... (9 Replies)
Discussion started by: shifahim
9 Replies

7. UNIX for Advanced & Expert Users

Help! How to find the local host after few ssh hops to remote host???

I do a ssh to remote host(A1) from local host(L1). I then ssh to another remote(A2) from A1. When I do a who -m from A2, I see the "connected from" as "A1". => who -m userid pts/2 2010-03-27 08:47 (A1) I want to identify who is the local host who initiated the connection to... (3 Replies)
Discussion started by: gomes1333
3 Replies

8. Shell Programming and Scripting

Run a shell script from one host which connext to remote host and run the commands

I want to write a script which would run from one host say A and connect to other remote host B and then run rest of commands in that host. I tried connecting from A host to B with SSH but after connecting to host B it just getting me inside Host B command prompt. Rest of the script is not running... (6 Replies)
Discussion started by: SN2009
6 Replies

9. Shell Programming and Scripting

host cp in ksh script not working

The following script is designed to backup the oracle control file to the trace directory and then copy (the trace file that was created by the backup command) and rename that file(to a .sql) to a backup disk. When I run the script from sqlplus as sysdba everything works but when I execute from... (1 Reply)
Discussion started by: tparker123
1 Replies

10. UNIX for Advanced & Expert Users

Running command "md5" on remote host not working.

My question is very strange. I can run ls command on remote host using ssh successfully. but when i try to run /sbin/md5 command on remote host. it doesnt run and get back to me on command prompt. md5 command is exist on remote host. This is what i tried which ran successfully. Query -... (1 Reply)
Discussion started by: ynilesh
1 Replies
Login or Register to Ask a Question