Los Angeles1
asked on
Linux,scripting with ssh and sshpass
I can get the ssh command to remotely perform file with commands such as ls -la, etc, but I am having difficulty in some other areas:
I have two scenarios, one works, the other does not:
WORKING SCENARIO
I have 2 ssh session running and do the following:
First session:
I start an ftp session
The second session
I kill the ftp session
[root@xxclnt1 home]# cat test.sh
pkill -9 ftp
[root@xxclnt1 home]# ./test.sh
[root@xxclnt1 home]#
The first session then successfully terminates the FTP
[root@xxclnt1 etc]# ftp
ftp> Killed
[root@xxclnt1 etc]#
NON_WORKING SCENARIO
The first session starts ftp as before
The second session then calls ssh to perform the test.sh (on the same machine as the caller, trying
to understand how this works so I can write more meaningful scripts involving terminating remote clients)
However, the ftp is still alive in the other session, and can also been see with the ps command
1> Most importantly, why did the test.sh fail to work
2> and how can I get it to work ?
Thanks
I have two scenarios, one works, the other does not:
WORKING SCENARIO
I have 2 ssh session running and do the following:
First session:
I start an ftp session
[root@xxclnt1 etc]# ftp
ftp>
The second session
I kill the ftp session
[root@xxclnt1 home]# cat test.sh
pkill -9 ftp
[root@xxclnt1 home]# ./test.sh
[root@xxclnt1 home]#
The first session then successfully terminates the FTP
[root@xxclnt1 etc]# ftp
ftp> Killed
[root@xxclnt1 etc]#
NON_WORKING SCENARIO
The first session starts ftp as before
[root@xxclnt1 etc]# ftp
ftp> Killed
The second session then calls ssh to perform the test.sh (on the same machine as the caller, trying
to understand how this works so I can write more meaningful scripts involving terminating remote clients)
sshpass -p 'xxxxx' ssh root@xxclnt1 /home/test.sh
However, the ftp is still alive in the other session, and can also been see with the ps command
[root@xxclnt1 home]# ps -ef | grep ftp
root 6471 6046 0 14:19 pts/1 00:00:00 ftp
root 6491 6445 0 14:21 pts/2 00:00:00 grep ftp
[root@xxclnt1 home]#
1> Most importantly, why did the test.sh fail to work
2> and how can I get it to work ?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
So I am starting with ftp as a client I am attempting to kill, and will work up to the more robust industry standard clients as I go