[solved] Killing 3rd command in ssh chain


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [solved] Killing 3rd command in ssh chain
# 1  
Old 09-28-2011
Computer [solved] Killing 3rd command in ssh chain

Hi All,

Noob question here...

How do I kill the 3rd command in this ssh chain effectively?

Code:
#  ssh -t -t 10.80.0.5 'ssh 10.80.0.6 | /var/tmp/some_script'

The "/var/tmp/some_script" contains:
Code:
ssh 10.80.0.81 'echo "Hello World!!!!" >> /tmp/sample.txt'

The problem is that once the sample.txt completes the ssh connection is still up. I want to kill it the script after it's done.

Smilie

---------- Post updated at 08:37 AM ---------- Previous update was at 07:59 AM ----------

I figured it out.

This solved it.
Code:
ssh -t -t 10.80.0.5 'ssh 10.80.0.6 | /var/tmp/vs_10.80.0.81 & sleep 2; kill %1'


Last edited by NYG71; 09-28-2011 at 09:34 AM..
This User Gave Thanks to NYG71 For This Post:
# 2  
Old 09-28-2011
Thanks!
Why are not all the users like you? (uses code tags, keeps us informed, and even changes the status!!! Wow...)

Have a great day
All the best
# 3  
Old 09-28-2011
Quote:
Originally Posted by NYG71
Hi All,

Noob question here...

How do I kill the 3rd command in this ssh chain effectively?

Code:
#  ssh -t -t 10.80.0.5 'ssh 10.80.0.6 | /var/tmp/some_script'

what is your goal with use ssh and script by pipe?
your script "/var/tmp/some_script" is processing and then closed connection when script is finished.
after this , you cannot get any output for connection pipe and therefore your process is hanging..

regards
ygemici
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Red Hat

iptables applied in local machine, can't ssh remote machine after chain changed to DROP

I want to SSH to 192.168.1.15 Server from my machine, my ip was 192.168.1.99 Source Destination was UP, with IP 192.168.1.15. This is LAN Network there are 30 Machine's Connected to the network and working fine, I'm Playing around the local machine's because I need to apply the same rules in... (2 Replies)
Discussion started by: babinlonston
2 Replies

2. Shell Programming and Scripting

[Solved] Replace character in 3rd column and leave 1rst and last

Hello to all, I have the following text where columns are separated by spaces. I want to have the 3rd column separating 3 strings with 2 "_" in the format below: LeftSring_CentralString_RightString So, in 3rd column I want to replace all "_" with "-", except the first and last "_" The... (5 Replies)
Discussion started by: Ophiuchus
5 Replies

3. Shell Programming and Scripting

[solved] Process ssh command in while loop

I have a script that reads a file containing a list of server names. It's suppose to loop through the list of names and execute a command on the remote server using ssh. It processes the ssh command for the first server in the list and then exits. Here's the code: #!/bin/bash ... (2 Replies)
Discussion started by: westmoreland
2 Replies

4. UNIX for Dummies Questions & Answers

[Solved] Cron - job to run every 3rd Friday of the month only

Hi Expert Please help me to set a cron job schedule, Ihave a job that run every 3rd Friday of the month at 1030am. I tried to set up like this, but the job still runs every friday at 1030am. I want the job to run every 3rd Friday of the month at 1030am only 30 10 15,16,17,18,19,20,21... (2 Replies)
Discussion started by: kaibiganmi
2 Replies

5. Shell Programming and Scripting

[SOLVED] put dd | ssh command in backgound

Greetings, I have an issue that has baffled me. I have done many searches, read the man documentation, and I have yet to find a solution. I am trying to run the following command within a script to copy a file across servers: $(dd if="$FDIR" bs=1024 2> /dev/null | ssh "$(whoami)@$SERVER"... (5 Replies)
Discussion started by: unaligned
5 Replies

6. Shell Programming and Scripting

SSH and Backticks [solved]

I have been testing a new script and cannot figure out why my `cat spath` will not execute on the remote machine? sudo ssh -p 22344 -o "PasswordAuthentication no" -o "HostbasedAuthentication yes" -l testuser 192.168.1.6 "find `cat spath` -depth" cat: spath: No such file or directory but... (0 Replies)
Discussion started by: metallica1973
0 Replies

7. Shell Programming and Scripting

run command with ssh[solved]

Hi all, Is it possible to make this possible ? $ echo $SKY_HOME /var/sink/SKY $ echo $SKY_HOME /home/smily/SKY $ ssh root@xyz "echo $SKY_HOME" root@xyz 's password: ****** /home/smily/SKY wrong output I was expecting the output as /var/sink/SKY (3 Replies)
Discussion started by: linuxadmin
3 Replies

8. UNIX for Advanced & Expert Users

[SOLVED] No INPUT chain on nat table in iptables

Hello, I'm having problem with an iptables rule. It seems that on one of two systems on the nat table, the INPUT chain doesn't exist for some strange reason. I get the error below: # iptables -t nat -A INPUT -j ACCEPT iptables: No chain/target/match by that name. Here is my kernel on... (0 Replies)
Discussion started by: Narnie
0 Replies

9. Shell Programming and Scripting

Strange terminal behaviour after killing ssh

Hi, We have a problem where occasionally an ssh will hang for no apparent reason preventing the rest of the script continuing. To deal with this I am trying to write a wrapper script to kill a hung ssh command after a specified period. The scripts use a sleep command running in the... (2 Replies)
Discussion started by: RECrerar
2 Replies
Login or Register to Ask a Question