Problem with logging into remote host


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem with logging into remote host
# 1  
Old 06-13-2006
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  
Old 06-13-2006
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  
Old 06-13-2006
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  
Old 06-13-2006
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 07:02 AM..
# 5  
Old 06-13-2006
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check/get the exit status of a remote command executed on remote host through script

Geeks, Could you please help me out in my script and identify the missing piece. I need to check/get the exit status of a remote command executed on remote host through script and send out an email when process/processes is/are not running on any/all server(s). Here's the complete... (5 Replies)
Discussion started by: lovesaikrishna
5 Replies

2. Shell Programming and Scripting

Logging the IP from original host not the jumphost

how can you log the ip from their each host? not from jump host? is there anyway regex can do that? example. server1.yourownhost server2.jumphost server3.outsidehost If you will login to server3.outsidehost, then you will issue the command last. the ip address server2.jumphost,... (3 Replies)
Discussion started by: kenshinhimura
3 Replies

3. Shell Programming and Scripting

Pause processes in remote host and resume execution in another remote host

Hi, Given addresses of 2 remote machines, using a shell script is it possible to get the state of running processes in "src" stop all the processes in "src" exit out of "src" ssh into "dest" resume the state of executing processes captured in step 1 in "dest" Assumption: "src" is... (3 Replies)
Discussion started by: Saeya Darsan
3 Replies

4. Shell Programming and Scripting

Executing scipts after logging into a remote host using shell script

Hi All, Sorry if it is a duplicate post. I have not got any reference about this anywhere. I looked at the posts described in SSH - Passing Unix login passwords through shell scripts - Linux / UNIX Forum and it helped me till the point to connect to the host and executing the basic commands.... (3 Replies)
Discussion started by: RSC1985
3 Replies

5. Shell Programming and Scripting

Problem starting of Tomcat on remote host

Hi All, I have several Tomcat 7.0.12 installations on remote servers for different projects. I need to start and stop them from a centralized server. Once I start the server remotely using ssh commands, server starts successfully but prompt does not exit. It keeps on holding. I have... (4 Replies)
Discussion started by: bhaskar_m
4 Replies

6. SCO

sco remote logging problem

Hello, I am trying to write log from sco box to a remote host. We already have that setting working for linux server using syslog. With this setting(on LINUX) *.* @remote-host for sco I have this *.debug /usr/adm/syslog *.* ... (3 Replies)
Discussion started by: polestar
3 Replies

7. UNIX for Advanced & Expert Users

Help! How to find the local host after few ssh hops to remote host???

I do a ssh to remote host(A1) from local host(L1). I then ssh to another remote(A2) from A1. When I do a who -m from A2, I see the "connected from" as "A1". => who -m userid pts/2 2010-03-27 08:47 (A1) I want to identify who is the local host who initiated the connection to... (3 Replies)
Discussion started by: gomes1333
3 Replies

8. Shell Programming and Scripting

running commands to remote host from centralized host

Gurus/Experts We have a centralized UNIX/Solaris server from where we can actually ssh to all other UNIX/Solaris servers...I need to write a script that reside on this centerlized server and do FileSystem monitoring (basically run df -h or -k) of other remote servers and then send an email to me... (6 Replies)
Discussion started by: anjum.suri
6 Replies

9. Shell Programming and Scripting

Run a shell script from one host which connext to remote host and run the commands

I want to write a script which would run from one host say A and connect to other remote host B and then run rest of commands in that host. I tried connecting from A host to B with SSH but after connecting to host B it just getting me inside Host B command prompt. Rest of the script is not running... (6 Replies)
Discussion started by: SN2009
6 Replies

10. Solaris

How to delete the files from local host to remote host

Hi all, i am copying .gz files from production server to development server using "scp" command.my requirement is after copying .gz files i want to delete old .gz files(two days back) in development server from production server. like this way i need to delelte .log ,.z and .dmp files... (3 Replies)
Discussion started by: krishna176
3 Replies
Login or Register to Ask a Question