LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-29-2002, 03:33 AM   #1
richie-451
LQ Newbie
 
Registered: Jan 2002
Posts: 2

Rep: Reputation: 0
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
 
Old 01-29-2002, 03:43 AM   #2
richie-451
LQ Newbie
 
Registered: Jan 2002
Posts: 2

Original Poster
Rep: Reputation: 0
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!
 
Old 01-29-2002, 03:50 PM   #3
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
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/
 
Old 01-31-2002, 01:21 PM   #4
kervin
Member
 
Registered: Jan 2002
Location: Melbourne, FL.
Distribution: redhat
Posts: 168

Rep: Reputation: 31
<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>
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Bash function mijohnst Programming 13 10-23-2005 12:40 PM
Bash function pazvant Linux - Software 1 03-08-2005 07:47 AM
How do I add a function to Bash? Gag Halfrunt Linux - Newbie 5 11-25-2004 12:05 PM
Bash function parameter Misel Programming 2 05-17-2003 11:51 AM
compile within bash function? adam_boz Programming 1 09-17-2002 11:13 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration