LinuxQuestions.org
Review your favorite Linux distribution.
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 10-12-2006, 03:09 PM   #1
vswr31
Member
 
Registered: Apr 2004
Location: phoenix,az
Distribution: red hat/suse
Posts: 54

Rep: Reputation: 15
Question FTP issues


I am attempting to download a file that will begin with the date in this format: YYYYMMDDsomeending, I can get it to work without the ending but when i add some ending my syntax isnt correct.
Here is the line of the script that DOESNT work.
get $(date +%Y%m%e)'myfile'
 
Old 10-12-2006, 03:26 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
It could be your quotes. The following use of date works in bash:
Code:
echo $(date +"%m%d%Y")myfile
10132006myfile
I've also used %d instead of %e to give a number without space padding. According to man date:
Code:
%d     day of month (e.g, 01)
%e     day of month, space padded; same as %_d
 
Old 10-12-2006, 08:12 PM   #3
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Maybe I make a wrong assumption, but it looks like you are inside an FTP client and try to issue the date command. I am not sure if bash expands the $(date) before it feeds the command "get $(date)" to the ftp server.

If it does not expand, create the filename before you open the ftp connection, and then use ncftpget.

If you have multiple files to download, build a list first and then use ncftpget.

ncftpget is a batch mode ftp client.

jlinkels
 
Old 10-12-2006, 09:12 PM   #4
vswr31
Member
 
Registered: Apr 2004
Location: phoenix,az
Distribution: red hat/suse
Posts: 54

Original Poster
Rep: Reputation: 15
that's it

I figured this out about 20 mins after, but thanks for the quick response
 
Old 10-13-2006, 03:58 PM   #5
vswr31
Member
 
Registered: Apr 2004
Location: phoenix,az
Distribution: red hat/suse
Posts: 54

Original Poster
Rep: Reputation: 15
not so fast

I figured out that the date command was not expanding within the ftp session, but i still cant pass that value(output from date) to the ftp session
 
Old 10-13-2006, 06:26 PM   #6
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Can you put the code block here you are using for the ftp transfer?

Does this help you any further?

jlinkels
 
Old 10-16-2006, 12:32 PM   #7
vswr31
Member
 
Registered: Apr 2004
Location: phoenix,az
Distribution: red hat/suse
Posts: 54

Original Poster
Rep: Reputation: 15
#!/bin/bash

file=$(date +%Y%m%e)
echo $file
##wget ftp://testguy:space@10.21.8.58/$file (this works for retrieving the file, I need to be able to change to a directory that will be named 20061017(current date). and i need to pass that value to the ftp session.



ftp -in <<EOF
open 10.21.8.58
user testguy space
cd $file
get $file
rename $file processed
bye
EOF

Last edited by vswr31; 10-16-2006 at 12:35 PM.
 
Old 10-16-2006, 09:10 PM   #8
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
The only difference I can see is that in my example the variables are quoted, e.g.
Code:
get "$file"
instead of
Code:
get $file
It is mandatory in case your file contains spaces. (Which doesn't happen here)
If that doesn't help I don't know, sorry.

And be careful with
Code:
rename $file processed
After the first time you might try to rename to an existing file. I don't know if ftp can handle that.

jlinkels
 
  


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
ftp issues pumplove Linux - Networking 2 06-06-2006 11:23 PM
FTP issues colabus Debian 0 12-12-2004 10:46 PM
FTP issues dpp777 Linux - Networking 4 07-21-2004 10:46 AM
FTP issues with Slac proendo Slackware 3 01-29-2004 08:39 PM
FTP Connection Issues crowmanic Linux - Networking 1 03-06-2003 06:37 PM

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

All times are GMT -5. The time now is 05:34 AM.

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