Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

soure to remote location 1

Status
Not open for further replies.

Cimm

Technical User
Feb 17, 2005
69
US
Hi,

I need to make a ftp script, going into many different source locations , which has also different known destinations.

To make this ftp script as easy as possible for non-programmers to edit the source and destinations I would like to use a seperate directory list with source locations and the destinations after.

like.

/user/ftpid/* /extracts/incoming/inbox/
/user/craw/* /extracts/incoming/inbox2/

etc..
In other words, how can I assign temporary $source and $remote variables by using that list?

I need to read one line at the time, assigning the first "word" to a source varible, and the second "word" on the same line to a destination varible.

Any idea's ?

Thanks in advance.


 
In your shell man page take a look at the read builtin:
while read source remote
do
echo "source='$source', remote='$remote'"
done < /path/to/list

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
is it possible to do something like this with sed?

while read source remote
do
`sed 's!$source!$remote!g' ftp_out.log`
done < double_directory

The above is not working, but I couldnt find a better way to explain what I want to do.

 
Perhaps something like this:
while read source remote
do
sed "s!$source!$remote!g" ftp_out.log > ftp_out.tmp && mv ftp_out.tmp ftp_out.log
done < double_directory

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
thanks again, works great.
 
Ok, I guess I am on the last part now.
I have successfully formatted the logfiles now with the help above here.

Now I have 2 tmp files.
One with source location and the actual file name.
and the other one with the remote locations with the same file name.

There should be equal amount of lines in each of the files.
How can I combine them both to 1 single file with a space between the paths.

example.

source.tmp
remote.tmp

/user/ftpid/file1 /extracts/incoming/inbox/file1
/user/ftpid/file2 /extracts/incoming/inbox/file2
/user/craw/file3 /extracts/incoming/inbox2/file3

final_list

etc.

 
man paste

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
thanks.
Thats what I was looking for.
 
PHV or anyone else.

HOST=$1
shift

FILE_NAMES=$*
#
echo $FILE_NAMES
(
echo "bin"
for i in $FILE_NAMES
do
echo get $i
done
)| ftp -v -i $HOST

The plan is to echo out the finallist to the variable FILE_NAMES. However , ftp needs 2 arguments to do a get command successful.

get /user/ftpid/file1 /extracts/incoming/inbox/file1 <-WORK
get /user/ftpid/file1 <- Doesnt work

So because of this I need the 2 first arguments from the list, and then the next 2 and so on till the list is empty.
I went with shift but it just moves forward in the list, not actually giving me /user/ftpid/file1 /extracts/incoming/inbox/file1

I need $i to be /user/ftpid/file1 /extracts/incoming/inbox/file1

and not just /user/ftpid/file1

each line in the finallist looks like
/user/ftpid/file1 /extracts/incoming/inbox/file1

Any suggestions?

 
And this ?
(echo bin
while [ $# -gt 1 ]; do
echo get $1 $2
shift 2
done
)| ftp -v -i $HOST

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top