Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
The main body of this script works as expected when not written as a function.
When the script is written as shown below, the line "ftp -v -n <Does anyone know the proper syntax to write the line. I think it has something to do with possibly using the single quote, double quote, backslash or back quote charaters? Thanks,
Dave#!/bin/sh
# script1
# 2/19/02 by da
# This script moves a data file from Computer1 to Computer2
ftpit()
{
cp /home/jdoe/tmplun1/test1 /home/jdoe/tmplun1/junk99
ftp -v -n <open computer2
user xxxx pppp
cd /home/jdoe
!cd /home/jdoe/tmplun1
put junk99
close
quit
exit
cd /home/jdoe
}
if [ -s test1 ]
then
ftpit
fi

This is a correction to my original posting. The line should read "ftp -v -n <
ftp -v -n < open computer2
user xxxx pppp
cd /home/jdoe
!cd /home/jdoe/tmplun1
put junk99
close
quit
exit

Hello Dave !
The correct mode is:
ftpit()
{
cp /home/jdoe/tmplun1/test1 /home/jdoe/tmplun1/junk99
ftp -iv << EOF
open computer2
user xxxx pppp
cd /home/jdoe
lcd /home/jdoe/tmplun1
put junk99
close
quit
exit
cd /home/jdoe
EOF
}
if [ -s test1 ]
then
ftpit
fiLet me know if everything is OK.
Paulo Alves Vieira

David,
I tested your script in my server and I discovered the problem.
The word EOF is obligatory and has a positional field. Then put the word EOF at first field like the example.
After your test, please, e-mail me.I wrote the original script ( in blue letters ) and fixed ( in red letters), look !!!
ftpit()
{
cp /home/jdoe/tmplun1/test1 /home/jdoe/tmplun1/junk99
ftp -v -n <open computer2
user xxxx pppp
cd /home/jdoe
!cd /home/jdoe/tmplun1
put junk99
close
quit
exit
cd /home/jdoe
EOF
}
if [ -s test1 ]
then
ftpit
fi
Paulo Alves Vieira
Cartão Unibanco - Arquitetura Técnica
F: 3789-7024 - CAU C2

Hi folks,
The construct which is used here is called "HERE DOCUMENT".
This means that everything that comes between the "beginning marker" and the "end marker" is treated as if it would be keyed in directly on the terminal.
The "beginning marker" has always the form: lt-sign lt-sign keyword
and the "end marker" is just the
keyword
Typically the keyword is EOF but other words are also possible.
(The lt-sign doesn't work well, if I enter it in this amilbox, for that reason I just used the words, but you have to use the sign, which spells in HTML as & l t ; "<" and is on my us-keyboard on Shift-comma)

I want to do ftp by using shell script, presently it is working.
but I want to do
ftp -n -i password mput etc..
as a single line command
I do not want to on next line...

![]() |
somebody is looking my fi...
|
hmmmm
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |