Sponsored Content
Top Forums Shell Programming and Scripting SSH execute remote command (with jump) Post 302455196 by vistastar on Tuesday 21st of September 2010 04:43:52 AM
Old 09-21-2010
Maybe this works:

Code:
#!/usr/bin/expect
spawn ssh usr1@IP_of_B1 ssh usr2@IP_of_B2 pwd #pwd is the command you wanna execute on B2
expect "password"
send "passowrd_of_usr1\n"
expect "password"
send "passowrd_of_usr2\n"
expect eof
exit


Last edited by vistastar; 09-21-2010 at 05:49 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

execute a command in remote

how exec a command (ex. a cut or grep ) in anoter pc i have IP address, login and password. (another account of unix system) what's the sintax of command ??? es. my ip is 192.xx.xx.xx i make a exec of "ls" redirect in outpu file (> "file) in another pc ( ip 192.44.55.2xxx) (3 Replies)
Discussion started by: ZINGARO
3 Replies

2. SCO

Execute command in remote

Hi, How to execute unix commands in remote unix servers? Thanks, Pintu (2 Replies)
Discussion started by: pintupatro
2 Replies

3. Shell Programming and Scripting

How to execute remote ssh command - Perl and CGI

Hi, I am having nightmare issue-ing remote ssh command from a CGI perl script. It just won't run on debug message: It says permission denied. Can I even do this? as the apache server running under DAEMON account probably can't execute it? Is this the case of what's going on? Here is my... (3 Replies)
Discussion started by: Dabheeruz
3 Replies

4. Shell Programming and Scripting

ssh to remote host and execute command

Hi, could anyone please tell me how to ssh to remote host foo and execute command on it and print the result on local host? Thanks, Paresh (1 Reply)
Discussion started by: masaniparesh
1 Replies

5. Shell Programming and Scripting

Using ssh to execute a remote script in the background

Help please!! I want to use ssh to execute a remote exe and while it's running I want to query for the process ID of the exe (2 different ssh commands) 1. sshpass -p "<passwd>" ssh -f -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@<ipaddress> nohup /tmp/mmds_asyn & 2.... (0 Replies)
Discussion started by: rvompoluTMW
0 Replies

6. Shell Programming and Scripting

bash script to execute a command remote servers using ssh

Hello, I am running into few issues, please suggest me what I am missing. I am running this script on a linux host. Main idea of this script is to, login to each host via ssh and get uid of user, service user that I trying to run this script, has already deployed ssh keys and provide sudo... (8 Replies)
Discussion started by: bobby320
8 Replies

7. Shell Programming and Scripting

Shell script help to execute ssh remote commands

Hi, The below command is not giving me the count , Can somebody help me in re-writing this pls . Proc_Exist=`ssh -q -o "BatchMode=yes" -o "PasswordAuthentication=no" $OAUSER@${Primary_Node} ps -ef | grep -v grep | grep "${ICM_Proc}" |wc -l ` Also the same problem with below... (13 Replies)
Discussion started by: Y.balakrishna
13 Replies

8. Shell Programming and Scripting

Execute command on remote host via ssh

How should i make the following code working #!/bin/bash INPUTFILE="test.txt" while read STRING; do IP=`host -t A $STRING | awk '{print $NF}'` HOSTNAME=`ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no $IP "hostname"` echo $HOSTNAME > out.txt done < $INPUTFILE At this moment while... (3 Replies)
Discussion started by: urello
3 Replies

9. Shell Programming and Scripting

Execute ssh command with additional terminal command to any remote user not working script

Hello i am having an issue with bash script and this is the code now=$(cat hosts1.txt | awk '{print $2;}') while read n ;do ssh root@$now 'useradd test1; echo -e "test1\ntest1" | passwd test1 && echo "test1 ALL=(ALL:ALL) ALL" >> /etc/sudoers' When i execute only part with cat, it... (8 Replies)
Discussion started by: tomislav91
8 Replies

10. UNIX for Beginners Questions & Answers

How to execute setDomainEnv.sh in wblogic via ssh on remote server in shell script?

How to execute setDomainEnv.sh in wblogic via ssh on remote server in shell script we execute setDomainEnv.sh manually as . ./setDomainEnv.sh from its location ie /opt/SP/users/domian/bin" My approach is not working. Please advise. #!/bin/bash set -x base="/opt/SP/users/d1/bin"... (5 Replies)
Discussion started by: abhaydas
5 Replies
cmexec(1m)																cmexec(1m)

NAME
cmexec - Execute process on a remote Serviceguard node. SYNOPSIS
cmexec node_name [-o outfile] [-t timeout] {[command] | [-k cmd_label]} DESCRIPTION
cmexec will execute a process on a remote Serviceguard node and return any output or return value. cmexec is limited in several ways. cmexec is best suited for situations where other remote execution facilities are not available. For a more full featured tool for remote execution within a cluster, see cexec(1m) provided by Distributed Systems Administration Utilities. To use this command, the local user must have the root access role on the remote node. For more information on Serviceguard access control policies, see the manual, Managing Serviceguard. The command will be executed in an environment which matches the local node. All environment variables defined locally will be available on the remote node. Output from stderr and stdout for the remote process will be combined and delivered in one transmission. This command should not be used for interactive commands or commands which will return large quantities of output. Input via stdin is not supported. Killing the cmexec process does not stop the remote execution of the command. cmexec should not be used on any command which may hang without specifying a timeout value. Options And Arguments cmexec supports the following arguments: -o outfile Write output to the specified file instead of stdout. -t timeout Kill the executed command if it does not exit within the specified timeout (in seconds) node_name Serviceguard node to execute command on. command Command to execute on remote node. May be quoted. -k cmd_label This option is only supported for applications provided by Hewlett-Packard. RETURN VALUE
cmexec returns the exit value for the remote command or 1 if there was an error communicating with the Serviceguard node. EXAMPLES
Execute an 'ls' in a remote directory. cmexec node ls /tmp AUTHOR
cmexec was developed by HP. SEE ALSO
rsh(1), ssh(1), cexec(1m), cmcp(1m), cmdo(1m), cmsync(1m), cmquerycl(1m), cmviewcl(1m) Requires Optional Serviceguard Software cmexec(1m)
All times are GMT -4. The time now is 05:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy