Running Script from Telnet - Problems


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Running Script from Telnet - Problems
# 1  
Old 10-03-2006
Running Script from Telnet - Problems

...so I read "The Pragmatic Programmer" and they stressed the value of learning shell scripting!

I'm in a UNIX environment but have a Windows XP workstation.

I'm using Telnet to issue UNIX commands. I've done plenty of chmod's, command line ftp and stuff, but written no scripts to this point.

I've written a simple script with commands which work on the command line, but not from the script.

In essence it's this:

1. #!/bin/sh
2. echo "starting..."
3. ftp -inv <<EOF
4. open <host>
5. user me mypwd
6. cd /dir/xml/
7. mput /dir/xml/*.*
8. quit
9. EOF

When I run it line 6 produces a 250 CWD command successful
line 7 produces "?Invalid command"

At least I think its line 7 - it doesn't actually say.

Appreciate any pointers to get me going on this.

Thanks,

Paul
# 2  
Old 10-03-2006
When you're inside a program, like ftp, scripts are not what you need. You can try
one of these ways to make it work:
one way:
Code:
echo "
verbose
open <remote_node>
user <username password>
lcd </path>
cd </remotepath>
pwd
get somefile
bye 
" | ftp

or with a here document
Code:
ftp remote_node <<EOF
user <username password>
lcd </path>
cd </remotepath>
pwd
get somefile
bye 
EOF

<<EOF marks the start, EOF marks the end of the here document.

If you are using ksh consider coprocesses - search the FAQ here for ftp.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Error while running xterm in telnet script

Error: Type xterm -help for a full description. xterm: Explicit shell already was /root/Desktop/telnet.sh xterm: bad command line option "Done!" usage: xterm (0 Replies)
Discussion started by: sk151993
0 Replies

2. Shell Programming and Scripting

Problems running script in cron...

Hi all, I have a script running on a Solaris 8 box and the first thing it does it check which user is executing it; if ; then echo "This script must be run as testuser" 1>&2 exit 1 fi This works fine when manually running the script however when adding into that users' crontab it... (1 Reply)
Discussion started by: JayC89
1 Replies

3. Red Hat

Problems with script running with crontab

Hi, I'm trying the backup a few information commands of my Check Point FW (it's on a SPLAT linux machine). This is the script I wrote: #!/bin/bash cd /var/tmp/ file1=netstat_`/bin/date +%d%m%y`.txt file2=ifconfig_`/bin/date +%d%m%y`.txt file3=cpstatos_`/bin/date +%d%m%y`.txt... (2 Replies)
Discussion started by: nirsh
2 Replies

4. UNIX for Dummies Questions & Answers

Problems running script on remote Terminal

Hi, I'm new here so please excuse any stupidity that occurs in my post :P My situation: Have a java program which I have to run a ridiculous amount of times and put the output data into a text file. Thought the easiest way to do this would be to delve into the world of scripts. I am at home... (1 Reply)
Discussion started by: lozyness
1 Replies

5. AIX

Problems with SSH / telnet

Hey, I have upgraded 3 servers from SSH Tectia 4.0.3 to SSH Tectia 6.0.2. 2 of them are working fine but one server suddenly began to have troubles after about 2 hours. Now it is impossible to login to this server using SSH and even telnet. When SSH is running on this particular server, the CPU... (20 Replies)
Discussion started by: Hille
20 Replies

6. Shell Programming and Scripting

Problems in running a Perl script via cronjob

I have a very basic perl script that attempts to find if a process is running. If the process is not running then the script is supposed to start the process. If I execute the script from command line it works fine as expected. However if the script is executed via cronjob, the script cannot find... (1 Reply)
Discussion started by: ypant
1 Replies

7. Solaris

running script after closing telnet

Hi Guys, I have a question, is there a way or an option where i can run a script continuesly after i close the telnet window?? because im running a cobol program which runs several hours and im thinking that ill run it after office hours so the run will be finish the next day.. the thing is i need... (2 Replies)
Discussion started by: shinjeck
2 Replies

8. UNIX for Dummies Questions & Answers

problems running a sql loader script

Hi Folks, I have created a number of unix scripts that i can run from the scheduler on a server-side application that we use (Chordiant Marketing Director). All scripts are working except one. This last script is a user load script which first truncates a table and then loads it using a flat... (2 Replies)
Discussion started by: jibbadiah
2 Replies

9. UNIX for Dummies Questions & Answers

Problems with telnet.

Hi Guys! I'm trying to connect to a regatta IBM (Sun 5.8) from my recently installed Sun Blazer, but I got the following: % telnet regatta Trying 167.164.87.8 Connected to regatta Escape character is '^]' Connection closed by foreign host % Do you have any idea what the problem is?... (2 Replies)
Discussion started by: cordobapablo
2 Replies

10. UNIX for Dummies Questions & Answers

Problems with Telnet

Hi everybody I already have installed Linux Red Hat FC4 in two machines into the same net using DHCP in both of them, the network interface are working fine cuz i can surf in Internet in those machines The problem is i need to do a Telnet from one host to the other, the xinetd and telnet... (1 Reply)
Discussion started by: Lestat
1 Replies
Login or Register to Ask a Question