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

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:

echo "
verbose
open <remote_node>
user <username password>
lcd </path>
cd </remotepath>
pwd
get somefile
bye 
" | ftp 

or with a here document

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.