Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

The following is working as expected. The only problem is that it does not return the source server command prompt unless I hit Ctrl + c

[abc@server]$ 0</dev/null echo "ls" | ssh  -t -t abc@10.10.10.124 "sh"
tcgetattr: Invalid argument
sh-3.2$ xyz.tar.gz
sh-3.2$ Killed by signal 2.
[abc@server]$ 

I want to use it in shell script.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Why not:

$ ssh -t -t abc@10.10.10.124 'ls && exit'

The actual command is echo "file.txt" | ssh -t -t ...

I think you mean cat file.txt (file.txt contains all the commands which you want to execute on the remote server), and if so, just append exit to the end of this file:

$ sed '$a exit' file.txt | ssh -t -t abc@10.10.10.124
  • $ is used to indicate the last line
  • a stands for append
share|improve this answer
    
It is part of shell script. The actual command is echo "file.txt" | ssh -t -t ... # Update: I can change echo to standard in < # got it # thanks –  shantanuo Oct 13 '11 at 5:49
    
I still have to use ctrl + C to get out of the prompt. Any other tip? –  shantanuo Oct 13 '11 at 7:25
    
check out my updated answer. –  quanta Oct 13 '11 at 7:45
    
brilliant answer. –  shantanuo Oct 13 '11 at 10:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.