1827007 Members
2559 Online
109712 Solutions
New Discussion

Re: autamatic telnet

 
k.s.chakravarthy
Occasional Contributor

autamatic telnet

can any one tell me the code for the following task..
script has to automatically telnet/or ftp to one location and should store the out put of the df -k .. in a variable and i hav to use this variable after comming out from the script

Thanks in advance
chakri
coolchecks
3 REPLIES 3
Patrick Wallek
Honored Contributor

Re: autamatic telnet

Can you use something like remsh instead of telnet?

Your variable could be something like:

dfvar=`remsh remotehost df -k /filesystem`

If not remsh, what about ssh?
Michael Tully
Honored Contributor

Re: autamatic telnet

Hi,

If you want to automate this task there are
two ways to go about it.
First you could use a remote shell (remsh)
from server A to server B or you could use
a script to pick up the files. I've attached
a sample script to help, or you could have
a look in the below link which has some good
information.

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x83e45f260cafd4118fef0090279cd0f9,00.html

HTH
-Michael

Anyone for a Mutiny ?
Ron Kinner
Honored Contributor

Re: autamatic telnet

I stole this fragment of code from a forum post by Kenny C. This shows you how to get a telnet seesion to start automatically and run a command. If you redirect the last line to a file then you have the info you need on your own machine and then it's just a matter of grepping it out.

Ron

# hostname is the name of the remote machine
# username is the name of the user
# password is the password of the user username

REMOTE=hostname #or IP address
(sleep 5
echo username
sleep 5
echo password
sleep 15
echo "ls -ald /tmp" #Your command
sleep 5
echo exit) |telnet $REMOTE