Problem with ssh termination...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem with ssh termination...
# 1  
Old 08-18-2010
Error Problem with ssh termination...

hi all,

i have a situation where i run ssh command from a unix machine to execute few scripts on 2 other unix machines.


my problem is, the scripts that i run will start few commands on the 2 servers and will quit....i am able to quit from the script but i have to give ctrl+c (on the server from where i am executing ssh) to exit from an ssh session.This situation is gettin worse when i try to run those scripts on 20 machines.i need to give a ctrl+c everytime.


can someone give a suggestion...



thanks in advance...
# 2  
Old 08-18-2010
Hi,

I have some questions:
- The script you run on the remote servers, you developed them? How do you "exit"? Are you sure the scripts finished?
- How are you executing the scripts on the remote servers?
# 3  
Old 08-18-2010
yes i developed those scripts. i actually run vmstat,iostat on server.i just give "exit" in the script which runs on the destination server.


ssh ${HOST} '/ravi/test/stat_collect.ksh start'


HOST is the variable that has the host on which i execute


where start is a parameter to the script.
# 4  
Old 08-18-2010
This one works to me:

Code:
testuser@remotesvr # more test.sh
#!/bin/sh
iostat
exit

Code:
[localsrv]fmv:/home/fmv/scripts/tmp>echo "./test.sh" | ssh -T -C -l testuser remotesvr
Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
   tty        md10          md11          md12          md20           cpu
 tin tout kps tps serv  kps tps serv  kps tps serv  kps tps serv   us sy wt id
   0  108  15   2   27   12   2   20   12   2   20    0   0   16    1  2  0 97

I have ssh keys on each server so I don't need to provide a password.

Let me know if it works for you.
# 5  
Old 08-18-2010
no its not working.....


it says "Name or service not known"




client:
Code:
ssh ${HOST} '/ravi/test/stat_collect.ksh start'


server:
in stat_collect i run iostat

---------- Post updated at 08:32 AM ---------- Previous update was at 08:29 AM ----------

when i use "-T -C -l" options to my ssh cmd i got that error
# 6  
Old 08-18-2010
Before executing your script, let's create a simple one and try to solve the problem, after we can go on.

On the remote host create this script in the user's home directory:
Code:
# cat test.sh
#!/bin/sh
echo "Arguments: [$*]"
iostat
exit

On the local host execute the following command:
Code:
# echo "./test.sh start finish" | ssh -T -C -l <RemoteUser> <RemoteServer>

The error you faced: "Name or service not known" is because of the wrong position of the arguments I gave you and you used wrongly.

Let me know the result.
# 7  
Old 08-18-2010
its working....but i want that iostat to continue running on the server and quit from ssh
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Email alert after termination

I am running the gaussian program on UNIX with bash and I want to form a script that will email me once the output life terminates either "normal termination" or "false" I just started learning this last week so could you let me know how to go about this.:b: (13 Replies)
Discussion started by: Jade_Michael
13 Replies

2. AIX

A question about scsi termination

http://ep.yimg.com/ay/iercomputer/ibm-39j5022-ultra320-scsi-adapter-dual-channel-pci-x-fc5736-3.gif I have bought this controller. Simple and fast question: I will put on this controller a external LTO tape,which is terminated with a terminator. I have to put another terminator on PCI-controller... (1 Reply)
Discussion started by: Linusolaradm1
1 Replies

3. Shell Programming and Scripting

Cat termination in script

So, I'm writing a shell script to help automate a process I'm doing. Basically I want to take input from the user for 2 variables, then create a file that consists of: Variable1,Variable2 Constant1 Constant2 .. Constant2000 then run an awk script. I'm pretty new to unix though, and so... (11 Replies)
Discussion started by: Parrakarry
11 Replies

4. Shell Programming and Scripting

Catching the termination of one script

Hi I have a Shell script that needs to execute a command at the End of the excursion of other script And I cant get a handel On the trap command. And that is if the trap command Is the proper way to go this is a extract of the script MYHOST=`hostname| cut -d. -f1` echo $MYHOST ... (4 Replies)
Discussion started by: Ex-Capsa
4 Replies

5. Shell Programming and Scripting

random script termination

I'm writing a script to archive data. First, the files are all rsync'd to the archive directory via NFS mounts(I know not the most efficient, but the only choice in this situation), then I use md5sum to validate the transfers. During execution of the script, it will exit for no apparent reason. It... (6 Replies)
Discussion started by: mph
6 Replies

6. Programming

does snprintf guarantee null termination?

Hi All, I was reading the man page of snprintf function and it saids that snprintf adds a null terminator at the end of the string, but I remember once someone told me that snprintf doesn't guarantee the insertion of a null terminator character. What do you think? Does anyone have experience... (4 Replies)
Discussion started by: lagigliaivan
4 Replies

7. Programming

handling abnormal process termination

hi i m writin a program in which i keep track of all the child processes the program has generated and if a child process has an abnormal termination i need to do certain task related to that child process. for handlin child process i used waitpid: temp_cpid=waitpid(-1,&stat,WUNTRACED); ... (4 Replies)
Discussion started by: mridula
4 Replies

8. UNIX for Advanced & Expert Users

Child peocess termination.

Hello all, Here is the problem: A ksh script (let's call it abc.sh) gets kicked off from a menu program using "nohup abc.sh &". The process ID of abc.sh can be recieved (pid=$!). abc.sh runs an Oracle PL/SQL script (it creates a child process). In order to stop the abc.sh (and the child)... (5 Replies)
Discussion started by: Shaz
5 Replies

9. UNIX for Dummies Questions & Answers

Abnormal Termination errors

I'm having trouble with Abnormal Termination errors. What are they, what causes them and how can I prevent them from happening? Are they application specific? (2 Replies)
Discussion started by: bialsibub
2 Replies
Login or Register to Ask a Question