trouble with moving a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting trouble with moving a file
# 1  
Old 12-27-2008
Data trouble with moving a file

Hi ,
I'm not so new to linux but very very rusty. Trying to migrate my solar / wind power web server from Windows XP runnning apache to linux. I have the first part of the ftp down as you can see below. I'm having a problem once I have identified the daily file. I'm not being very clear with my code to allow me to ftp the file from the controller to my linux server.

Any thoughts would be appriciated.


bash autoftp.sh >autoftp.txt | tail -n1 autoftp.txt >recent.txt |
tail -c15 recent.txt >solar_ftp_file.txt | cat solar_ftp_file.txt

I'm FTp to a controller running windows CE 4.2. I ftp to the box and run a list of the files in the directory. Then I tail it to get the most recent entry. Then I tail again to isolate and identifiyng the most recent file (Today) and putting it into a file solar_ftp_file.txt. Once I have the file name I try to integrate the file name into the ftp script.

I can't seem to integrate it to an FTP script to extract the file to my linux box. The goal is to bring the csv file to the linux box for processing.
# 2  
Old 12-27-2008
the second FTP file to extract the file from the controller to the linux box.

#!/bin/bash

HOST='webbox'
USER='User'
PASSWD='sma'
FILE={cat solar_ftp_file.txt}

ftp -i -n $HOST <<EndFTP
user ${USER} ${PASSWD}

cd DATA
cd 2008
bin
hash
prompt
get ${FILE}
bye
EndFTP
# 3  
Old 12-27-2008
Hi, I might be way off, but since I'm asking for help, I might as well try to give some while I'm at it =)

If I understand correctly, you've managed to create/fill solar_ftp_file.txt properly; you just need the script in your second post to take it's contents and set a variable?

If so, you might change the braces in

FILE={cat solar_ftp_file.txt}

to '`' (reverse single quote -- I can't remember it's proper name)

FILE=`cat solar_ftp_file.txt`

When I modified the script to grab a test file from my inhouse ftp server, it worked once I made that change.

Hope that helps =)
# 4  
Old 12-27-2008
you nailed it

Thank you,

That was it. I have since streamlined things as well.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Trouble with archiving; only works if file exists already

Hi Folks - I have a script I am executing that I wish to archive the output(logfile) file once the script is done executing to a folder based on the following date format: YYYYMM For this example purpose, I am performing a simple MKDIR. The script works fine, but the archiving is the... (7 Replies)
Discussion started by: SIMMS7400
7 Replies

2. Shell Programming and Scripting

Trouble reading content of file from a variable

Hi , i have a parameter which has path of a file. Now i need to have another parameter with the content of that file. I tried the belwo script , can any one please help. I dont want to use cat command to read. Can we do it with out using cat command. while read line do... (9 Replies)
Discussion started by: Ravindra Swan
9 Replies

3. UNIX for Advanced & Expert Users

Need help on moving .csv file from UNIX to windows file path

Need help on moving .csv file from unix to windows file path. (1 Reply)
Discussion started by: lakshmanraok117
1 Replies

4. OS X (Apple)

CUPS file modified causing trouble

I have modified the CUPS file - (deleted the Pause Printer part ) and now I cannot access anything under localhost:631, or printer settings through System preferences. They just keep freezing and there is no way I can get back to edit the config file. Any suggestions? thank you... (2 Replies)
Discussion started by: Ladybird
2 Replies

5. Shell Programming and Scripting

Trouble with catting a file

I have a perl script I am trying to modify and I cannot seem to get it to do right. I want it if the -l is ran with the script to cat the given file and then exit. my ( $help, $version, $list ); my $query = 0; my $default = ''; GetOptions( 'd|default=s' => \$default, 'q|query=s'... (3 Replies)
Discussion started by: bigbenn
3 Replies

6. UNIX for Advanced & Expert Users

Trouble with log file..

Hi guys, I have to filter out certain patterns from a log file (arerror.log, for those who know BMC Remedy). The problem is that the file is big, too big to be read properly. Filters aren't working properly on the file, and neither the entire contents are visible using more, or vi. I FTP'd it to... (9 Replies)
Discussion started by: raj_55555
9 Replies

7. Shell Programming and Scripting

Trouble with sed and ini file parsing

hi people, i'm having a hard time trying to extract a list of vars delimited by section inside a ini file ... let's consider this ini file : ; config file DESC = "channel synchro TGG01" DMM_VER = DMM23 PATH_FIFO = /users/tgg00/fifo QRT = BTS01.TGG.01.2 MODE_TRACE... (5 Replies)
Discussion started by: odium74
5 Replies

8. Shell Programming and Scripting

Trouble printing multiple lines to a new file

Hi, I'm trying to auto generate some php files with a default preamble at the top which is a block comment. The problem is that my output has no new lines and it looks like the output from "ls" is being printed after everyline This is my code #!/bin/bash read -d '' pre_amble... (1 Reply)
Discussion started by: racshot65
1 Replies

9. Shell Programming and Scripting

Trouble reading [noeol] file

cat can't show the last line of a file sftp transffered from Windows, because the last line is not ended with new line. Vi can show all line with warning I can append blank line in order for cat to show all lines, But is there a command to do this without modifying the file? > cat -A... (3 Replies)
Discussion started by: honglus
3 Replies

10. Shell Programming and Scripting

Finding & Moving Oldest File by Parsing/Sorting Date Info in File Names

I'm trying to write a script that will look in an /exports folder for the oldest export file and move it to a /staging folder. "Oldest" in this case is actually determined by date information embedded in the file names themselves. Also, the script should only move a file from /exports to... (6 Replies)
Discussion started by: nikosey
6 Replies
Login or Register to Ask a Question