|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
how to use telnet in script
I am trying to use telnet in shell script but getting following error
error Connected to crmapp00.agf.ca. Escape character is '^]'. Connection closed by foreign host. Script #!/bin/ksh PATH=/usr/sbin/:/usr/bin:/usr/ucb:/etc:/usr/local/bin:. telnet HOSTNAME <<SCRIPT user userid password SCRIPT exit i think i am doing something wrong in this area user userid password Actually i have tried different way too but didn't work it prompt me for userid and password. #!/bin/ksh PATH=/usr/sbin/:/usr/bin:/usr/ucb:/etc:/usr/local/bin:. telnet HOSTNAME user userid password exit I'll really appreciate if someone can help me… Thanks in Advance. |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
You cannot use a here document with telnet.
If this task really must be done with telnet it could best be done with expect, otherwise use a login method which does not need interactive logins such as rsh/rexec or preferably ssh. |
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
Quote:
Here's the "poor-man's" inline telnet which might not be bullet-proof for all the cases: Code:
(
sleep 3
print user
sleep 1
print password
sleep 2
print "ls ~"
sleep 1
print "exit"
sleep 3
) | telnet hostname |
|
#4
|
|||
|
|||
|
Thank you so much it worked
|
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
this one is working, but it exits the telnet session at the end. i want the script to make a permanant connection to the server so that whenever i want to connect, i can just run the script instead of entering all the credinals.
Quote:
|
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
no, i dont ve pearl. i just want a script that can connect to server using telnet and therafter it should end, but not the connection
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Telnet script | Pouchie1 | Shell Programming and Scripting | 3 | 08-27-2010 06:08 AM |
| Telnet and ssh in a script | marwan | UNIX for Dummies Questions & Answers | 3 | 06-11-2007 10:58 AM |
| Telnet in a script | insania | Shell Programming and Scripting | 5 | 04-15-2007 01:32 PM |
| telnet through script | arun.viswanath | UNIX for Dummies Questions & Answers | 1 | 03-26-2006 11:33 AM |
| ksh telnet script | rwunwla | Shell Programming and Scripting | 5 | 12-16-2005 08:22 AM |
|
|