The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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



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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to delete the files from local host to remote host krishna176 SUN Solaris 3 03-24-2007 04:48 PM
logging to remote server abey Shell Programming and Scripting 6 03-21-2006 08:12 PM
How to specify the remote host? redlotus72 UNIX for Dummies Questions & Answers 2 07-21-2005 05:21 AM
FTP - Connection Closed By Remote Host mouglybean IP Networking 1 10-26-2004 09:15 AM
Delay when logging in remote alfabetman UNIX for Dummies Questions & Answers 8 10-08-2001 10:55 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-13-2006
patil_reddy patil_reddy is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 2
Problem with logging into remote host

Hi All,

I am using a script for remotely logging into a rhost using telnet and shutdown a server. The script is as follows.

IP = 10.24.12.23; export IP
UNAME = username ; export UNAME
PWD = password; export PWD
CRDIR = /etc/rc.d/init.d ; export CRDIR

echo "logging into remote host"

(
telnet $IP << EOF
$UNAME # username for logging into rhost
$PWD # password for logging

cd $CRDIR
sh shutdown.sh stop # for shutdowning the server
$PWD # password for shutdowning the server

logout
EOF ) >> log.$$

When I execute this script, I am getting an error saying that "unknown host". Can you please let me know what the problem is? If you know any other way of logging into a remote host. Can you please let me know ASAP.

THanks in Advance,
Patil.
  #2 (permalink)  
Old 06-13-2006
Klashxx's Avatar
Klashxx Klashxx is offline Forum Advisor  
HP-UX/Linux/Oracle
  
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 393
It seems to be a problem with blanks, try:
Code:
IP=10.24.12.23; export IP
UNAME=username ; export UNAME
PWD=password; export PWD
CRDIR=/etc/rc.d/init.d ; export CRDIR
  #3 (permalink)  
Old 06-13-2006
patil_reddy patil_reddy is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 2
Problem while logging into a remote host using telnet

Hi,

Thanks for the reply, but in the script whatever I have written has not blank spaces. It is returning an error

"Closed by a foreign host"


Please let me know if anyone has faced this error and what was the solution.

Thanks in advance,
Patil.
  #4 (permalink)  
Old 06-13-2006
Unbeliever Unbeliever is offline
Registered User
  
 

Join Date: Jul 2005
Location: England
Posts: 183
You cant use redirected input with telnet ... you need to use a tool like expect: http://expect.nist.gov/

Last edited by Unbeliever; 06-13-2006 at 06:02 AM..
  #5 (permalink)  
Old 06-13-2006
grial's Avatar
grial grial is offline Forum Advisor  
El UNIX es como un toro
  
 

Join Date: Jun 2006
Location: Madrid (Spain)
Posts: 531
Try something like this:

Code:

IP=10.24.12.23
UNAME=username
PWD=password
(
    sleep 2 
    echo "$UNAME"; sleep 2
    echo "$PWD"; sleep 2
    echo "pwd; whoami; hostname; exit"   # Commands here.
    sleep 2
) | telnet "$IP"
Regards.
Sponsored Links
Closed Thread

Bookmarks

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 On




All times are GMT -4. The time now is 12:32 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