LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   bash - ftp doesn't work within a function (https://www.linuxquestions.org/questions/programming-9/bash-ftp-doesnt-work-within-a-function-12952/)

richie-451 01-29-2002 03:33 AM

bash - ftp doesn't work within a function
 
HI
The following code works:
/usr/bin/ftp <<ENDFTP
open $intranet_server
cd $intranet_publish
mput $csv_output-*
y
bye
ENDFTP

The problem is when it's within an if statement or called from within a function. In both cases I get the error line (lastline): syntax error: unexpected end of file.

If I remove the << the function executes (though of course doesn't actually do anything)

Is there something I should be doing to escape the <<?

Thanks for any assistance.- Richie-451

richie-451 01-29-2002 03:43 AM

I've just figured the answer myself.

Within a function or an if statement the ftp commands must NOT have any leading tabs or spaces.

I don't know why!

crabboy 01-29-2002 03:50 PM

You are much better off using ncftp. It comes with ncftpget and ncftpput which are desinged to do command line ftp.

www.ncftp.com/ncftp/

kervin 01-31-2002 01:21 PM

<ramble>

Another possible route is using scp that comes with OpenSSH http://www.openssh.org and SSH http://ssh.com.

With the 'scp' command you can setup public key encryption which would allow your account to securely transfer data without the need to store your password in text files. And your script would be more like
scp $files user@$intranet_server:$intranet_publish

also, Expect http://expect.nist.gov/

</ramble>


All times are GMT -5. The time now is 10:57 PM.