Venus
Venus

Reputation: 1312

how to make sure commands in telnet is executed finished?

i want to invoke telnet from shell script,and let telnet execute some commands.

and tried below script .

sleep 3
echo username
sleep 3
echo password
sleep 3
echo "cp a b"
sleep 5
echo exit
sleep 3
)|telnet 192.168.22.11

  1. the problem is how can i know the command" cp a b " is finished. 5 second may not be enough.

  2. if i want to use if/else or something else in telnet,how can i write the shell script?

Upvotes: 0

Views: 161

Answers (2)

amdn
amdn

Reputation: 11582

Setup password-less ssh

http://www.linuxproblem.org/art_9.html

Then use ssh

ssh 192.168.22.11 cp a b

Upvotes: 1

Collin Grady
Collin Grady

Reputation: 2253

You can't do that without reading the output of telnet. You might have more luck with a tool designed to do this sort of remote running, like dsh, puppet, capistrano, or similar.

Upvotes: 0

Related Questions