I have written a script which ftp certain file to other machine and as the ftp completes , I want to connect to that machine ( at which the file is ftped) .
Now the problem is that my script ftp's the file but it does not telnet to that machine. Suppose I am at machine1 and I want to ftp and then telnet to machine2 I am writing my script as:
ftp machine2 << END_SCRIPT
-- some cmds--
--
--
quit
telnet machine2
--some cmds-
--
--
END_SCRIPT
My script is only ftping and not telnetting.... I don't know why. I have even tested this that It is not telnetting.
Hi vgersh99... thanks for all your replies.... Now what I am doing is that for telnet here-doc I am using
telnet machin2 << END_SCRIPT1
...
...
...
END_SCRIPT1
It let me connect to machine2 but It is asking me again for login and psw. But i am providing it at the begining of the script through variable....
I am pasting my actual script ( with some info changed) plz correct me if you see sth wrong in that.
I am ftping abc.tar from machine1 to machine2 and then trying to connect to machine2 to untar that file (abc.tar) at machine2.
The script is as follows:
USER=xxxxx
PASSWD=xxxxxx
cd /app/siebel/siebel7/siebsrvr
cd bin
echo Now at: `hostname`
pwd
echo =========================NOW FTPING========================================
ftp -n gpsappxxx.corporate.com<< END_SCRIPT
quote USER $USER
quote PASS $PASSWD
cd /app/siebel/swse/public/test
echo Now at: `hostname`
pwd
bin
put abc.tar
sleep 1
bye
END_SCRIPT
sleep 2
echo ============================NOW TELNETING===================================
telnet gpsappxxx.corporatecom
<< END_SCRIPT1
quote USER $USER
quote PASS $PASSWD
cd /app/siebel/swse/public/test
sleep 1
echo `tar -xvf abc.tar`
sleep 1
echo `rm abc.tar`
ls -ld
exit
END_SCRIPT1
echo Again at: `hostname`
pwd
I need an urgent help..... If possible plz modify the script if it is required.
This is what happening when I try run the script as you suggested for the telnet part:
$ ./telnet.sh
Trying 3.32.xxx.xxx...
Connected to gpsappxxx.corporate.com.
Escape character is '^]'.
SunOS 5.8
This computer system may be accessed and used only by company employees
and other authorized personnel and only for legitimate business purposes
and in accordance with applicable company policies and guidelines
The Company reserves the right to monitor access and use of Company
systems without any future warning, consistent with applicable law.
By accessing this computer system, you are consenting to monitoring by
the Company to ensure appropriate use and for other purposes. Unauthorized
access or inappropriate use may result in criminal penalties and/or
disciplinary action, up to and including termination.
login: xxxxxxxxxx
Password:xxxxxxxx
Last login: Fri Apr 28 10:26:53 from gpsapp***.corpo
Sun Microsystems Inc. SunOS 5.8 Generic Patch February 2004
$ ./telnet.sh: /app/siebel/swse/public/test: does not exist
Connection closed by foreign host.
----------------------------------
It is making conection with gpsappxx.corporate.com but not navigating to path /app/siebel/swse/public/test
But test directory exist in /app/siebel/swse/public .
Here is my telnet script:
USER=xxxxxxxx
PASSWD=xxxxxxxxx
cd /app/siebel/siebel7/siebsrvr
cd bin
(
sleep 1
echo "$USER"
sleep 1
echo "$PASSWD"
sleep 1
cd /app/siebel/swse/public/test
sleep 1
tar -xvf abc.tar
sleep 1
rm abc.tar
ls -ld
) | telnet gpsappxxx.corporate.ge.com
What can be done now dear ?. Is there any other way also to telnet from one machine to another using script ?
it wonders me that, even after modification... it is not letting me to go inside telnet loop.
(
...
...
...
) | telnet gpsappXXX.corporate....
It is not connecting to gpsappXXX.
Can some bdy suggest me different telnet script?.
Also I have checked the existing path to be correct. I am able to connect to gpsappXX from machine 1 when I go through each and every command manually....... but, not thriugh script????. Where is the problem?.
I have to get some telnet script..... plz help. May be your suggestion helps me . Plz suggest any other sol if possible.