ssh execute command remotely


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ssh execute command remotely
# 1  
Old 11-17-2011
ssh execute command remotely

Hi all,

Today I want to write a script to run the commands remotely.
If I run the command as follows:
Code:
ssh <user>@<ip> 'ls; pwd'

it works fine.

But when I want to use ssh to set view in clearcase, it will lose the response. as follows
Code:
ssh <user>@<ip> 'cleartool setview <view_name>; pwd'

What is the root cause of this? And how can I work out this problem?

Thanks
Damon


Moderator's Comments:
Mod Comment How to use code tags

Last edited by Franklin52; 11-17-2011 at 06:48 AM.. Reason: Please use code tags
# 2  
Old 11-17-2011
cleartool will set the session but ssh is waiting for the cleartool to return to execute the next command which will never happen until you exit from the view set. Once you do an exit, you will see that pwd gets executed. You can try this with a shell script also.

--ahamed
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

Execute a command after ssh exits

In my .tcshrc I define and run an alias to set my terminal title. The title contains the hostname. I do this because I ssh to other machines a lot and I always need to know which host I am typing in. The alias is defined and run in the .tcshrc like this... alias tt 'echo -n "^0;`hostname -s`^G"'... (5 Replies)
Discussion started by: salvadorjoshua
5 Replies

3. Shell Programming and Scripting

How to execute command remotely as sudo and save the output locally?

Hello , I am trying to run a NetBackup command in remote server. Also this command can only be run by root so I am using sudo . Also I want the output of the command locally in a file. The below command asked for password , ran successfully and showed Output on my local server screen ... (2 Replies)
Discussion started by: rahul2662
2 Replies

4. 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

5. Shell Programming and Scripting

Execute command using ssh server 'cmd'

Hi The command below does not work as it require to take command in the breakers But If I do so the variable values get lost ssh testserver01 'dsmc q b "${ARCHIVE_DIR}*" -sub=yes -querysummary -inactive -fromd="${BACKUP_DATE}"' Thank you. (3 Replies)
Discussion started by: zam
3 Replies

6. Shell Programming and Scripting

execute ssh command via perl

Hi I have a perl command that doesn't seem to be working correctly. It appears to be fine but even when i try and run it manually same thing. Can someone take a look at this and tell me what they think the problem could be? Here is the perl Line: system ("echo 'ssh -t -t $user\@$_ \"cd... (3 Replies)
Discussion started by: vpundit
3 Replies

7. UNIX for Dummies Questions & Answers

ssh command to execute shell script in another server

ssh -q <hostname> /opt/tcs/satish/tst.ksh ssh -q <anotherserver> /opt/tcs/satish/tst.ksh tst.ksh has "nohup <command> & " when i execute below script , its throwing error as nohup can not be found ssh -q <anotherserver> /opt/tcs/satish/tst.ksh > log & can someone let me... (5 Replies)
Discussion started by: only4satish
5 Replies

8. Shell Programming and Scripting

SSH execute remote command (with jump)

Hi all, I am facing the following issue: Host A should execute a remote command (say pwd) on host B2. B2 is not directly reacheable but you have to connect from a to B1, then from B1 you can execute the command ssh user@B2 pwd. B1 and B2 are directly connected: A => B1 => B2 | ... (3 Replies)
Discussion started by: Evan
3 Replies

9. 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

10. 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
Login or Register to Ask a Question