The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to use telnet in script sibghat Shell Programming and Scripting 9 1 Week Ago 08:35 AM
telnet through script arun.viswanath UNIX for Dummies Questions & Answers 1 03-26-2006 09:33 AM
ksh telnet script rwunwla Shell Programming and Scripting 5 12-16-2005 06:22 AM
telnet in a script vaccari UNIX for Dummies Questions & Answers 10 10-10-2001 08:37 AM
telnet in a script vaccari IP Networking 4 12-15-2000 12:42 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 06-09-2007
Registered User
 

Join Date: Mar 2007
Posts: 19
Telnet and ssh in a script

dear all,
I know that this question has been asked before frequently, but I really don't get it. My question is composed of several ones.

First:To telnet through a script, I was told to use the way described below, and it works for me, but i don't understand the syntax here. according to the piping, echoing the username, the password and the commands are done first, then the telnetting.. How is that?!
( echo open hostname
sleep 5
echo username
sleep 1
echo password
sleep 1
echo some more output, etc. ) | telnet

Second: Is that the only way that I can do telnet through a script in UNIX?
Third: What about SSH, I know that I can't do the samething with ssh, Is there another way??
Thanks for your concern...
Marawan
Reply With Quote
Forum Sponsor
  #2  
Old 06-09-2007
Registered User
 

Join Date: Sep 2006
Posts: 1,580
Quote:
Originally Posted by marwan
Second: Is that the only way that I can do telnet through a script in UNIX?
definitely not the only way. do you know any other programming languages? eg Perl/Python ? if you know them, there are telnet modules you can use to program telnet sessions.

Quote:
Third: What about SSH, I know that I can't do the samething with ssh, Is there another way??
ssh can execute remote commands. check your man page. it should be something like this: ssh <options> command
Reply With Quote
  #3  
Old 06-09-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by marwan
What about SSH, I know that I can't do the samething with ssh, Is there another way??
SSH is much more powerful, you use the command line and arguments to do the authentication and then stdin/stdout/stderr are effectively pure pipes to the shell or program at the remote end.

If you have your public key installed in your $HOME/.ssh/authorized_keys on the remote machine then all you need to do is things like

to get a remote directory listing...

Code:
ssh remote-host-name ls -l
or

Code:
ssh fred@foobar ls -l
or to unpack a tar file on a remote machine....

Code:
cat some.tar | ssh remote-host tar xvf -
Reply With Quote
  #4  
Old 06-11-2007
sysgate's Avatar
Unix based
 

Join Date: Nov 2006
Location: /root
Posts: 1,197
Take a look at this thread also, hope it helps a bit.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:19 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0