The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
grep unix.com with google



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-26-2009
Registered User
 

Join Date: Oct 2009
Posts: 8
Unhappy Using telnet inside a ksh

Hello,

i am trying to use telnet inside of a ksh script.
i would like to do like the following:

Code:
#!/bin/ksh
...
user="user"
hostname="hostname"
telnet -l $user $hostname |&
wait
#end of the ksh

and with this piece of code, i would like to telnet another machine, and let the user use telnet to work on the other machine.
It's like if the command was typed directly into the command prompt: the user then enters the password and continues working on the other machie until he types "exit" then he returns back to the first machine.
But it doesn't seem to work, i get "connection closed by foreign host" at the end of my script.
I hope you understand my problem. Can you please help ?
And idially, i would also like the script to enter the password automatically, if possible, but it's optionnal.

thank you very much.


Code:
$ uname -a
SunOS machinename 5.10 Generic_127111-06 sun4u sparc SUNW,Sun-Fire-V490

  #2 (permalink)  
Old 11-26-2009
Registered User
 

Join Date: Mar 2008
Posts: 1,350
Might be easier with the "rlogin" command?
Providing that the account name exists on both computers, "rlogin" can be configured to log in without a password.
  #3 (permalink)  
Old 11-26-2009
Registered User
 

Join Date: Oct 2009
Posts: 8
you're right it's easier.
but actually i had a problem using rlogin, it takes a long time before returning an error:


Code:
prompt $ rlogin XX.XX.XX.XX
::ffff:XX.XX.XX.XX: Connection refused
prompt $ telnet XX.XX.XX.XX
Trying XX.XX.XX.XX...
Connected to XX.XX.XX.XX.
Escape character is '^]'.

login:

but you know what, it's because i was using rlogin on the same machine, i guess that was the problem.
Thank you very much, i'm gonna switch back to "rlogin"

---------- Post updated at 02:19 PM ---------- Previous update was at 02:03 PM ----------

actually the was never the problem (rlogin to own machine)
do you know what could cause the "Connection refused" problem when using rlogin instade of telnet ?
  #4 (permalink)  
Old 11-26-2009
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,146
Try:
Code:
#!/bin/ksh
...
user="user"
hostname="hostname"
telnet -l $user $hostname
#end of the ksh


But to use telnet or rlogin, the remote system must be configured to allow it. rlogin is a very insecure program and most decent sys admins will prohibit it. (telnet isn't great for security either but it is better than rlogin.) If you get "connection refused" it is disabled, probably by intent.
  #5 (permalink)  
Old 11-30-2009
Registered User
 

Join Date: Oct 2009
Posts: 8
thank you for your reply.
but it still prompts me for the user and the password (i'm sure i have the "-l" option set).
i guess it is my only option
Sponsored Links
Reply

Bookmarks

Tags
unix telnet ksh

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
variable inside variable inside loop headache hcclnoodles Shell Programming and Scripting 6 06-18-2009 05:55 PM
value inside a function trichyselva Shell Programming and Scripting 2 08-04-2008 08:44 AM
Webpage to Telnet via Perl and Expect: Telnet problem? jondo Shell Programming and Scripting 1 07-22-2008 01:35 AM
looping a array inside inside ssh is not working, pls help reldb Shell Programming and Scripting 5 07-07-2006 11:32 AM
inside the JVM rein UNIX for Advanced & Expert Users 1 08-05-2005 02:57 PM



All times are GMT -4. The time now is 02:26 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0