Go Back   FlashFXP Forums > Community Chatter > Programming

Programming Need help with C/C++/Delphi? Ask here and make us all laugh.

Closed Thread
 
Thread Tools Rate Thread
Old 11-21-2005, 07:23 AM   #1
Senior Member
FlashFXP Scripter
 
Join Date: Jan 2002
Location: Madrid, Spain
Posts: 354
Cool .sh/.bat ftp script

Hi all.

After searching on Google and trying a couple of ideas ... i'm lost. Here we go:

1) There're two machines: one is Unix and the other one is Windows.

2) On Windows machine there're a couple of csv files (inside a folder called 'A') that should be transferred to Unix (to a 'B' folder) through ftp. I can use an .sh script (to 'get' files) or a .bat file (to 'put' files). The script will be executed every 10 minutes, every day. I can't use FlashFXP or other GUI client, only 'shell' scripting.

3) The tricky part is that for each file transferred i should move it to another folder: for each file transfered from 'A' Windows folder to 'B' Unix folder i should move it to 'C' Windows folder (a subdirectory inside 'A' Windows folder). This is to avoid the same file transfer on future script runs.

4) I know how to make a simple .bat ftp script that will upload one file to another host, but i'm really lost at how can i control that one file is transferred and once is transfered, move it to another folder.


Any ideas?.

Thanks in advance for your time.
DYN_DaTa is offline  
Old 11-21-2005, 02:25 PM   #2
Senior Member
Ultimate Scripter
 
Join Date: Jul 2005
Posts: 156
Default

this is fairly easy to do on the unix end, either with a shell script or python client. you might take a peek at the python ftp library, it might provide everything you need to whip up a simple script.
_panic_ is offline  
Old 11-22-2005, 05:14 AM   #3
Senior Member
FlashFXP Scripter
 
Join Date: Jan 2002
Location: Madrid, Spain
Posts: 354
Default

Thanks .

I'll take a look.
DYN_DaTa is offline  
Old 11-22-2005, 10:32 AM   #4
Posse Member
Ultimate Scripter
ioFTPD Administrator
 
Join Date: Dec 2002
Posts: 2,022
Default

Code:
md A\todo\
move A\*.* A\todo\
cd /d A\todo\
echo open remove_unix_host remote_port>ftp.instructions
echo username>>ftp.instructions
echo password>>ftp.instructions
echo bin>>ftp.instructions
echo mput *.*>>ftp.instructions
echo quit>>ftp.instructions
ftp -i -s:ftp.instructions
rm ftp.instructions
move *.* A\C\
cd ..
rd todo
??
Mouton is offline  
Old 11-22-2005, 02:14 PM   #5
Senior Member
FlashFXP Scripter
 
Join Date: Jan 2002
Location: Madrid, Spain
Posts: 354
Default

Nice one, Mouton, i'll try it. Thanks
DYN_DaTa is offline  
Old 11-28-2005, 01:38 PM   #6
Senior Member
FlashFXP Scripter
 
Join Date: Jan 2002
Location: Madrid, Spain
Posts: 354
Default

After a couple of tries i have a little .bat script that works :

Code:
@echo off
cd /D D:
if exist *.csv (goto si) else exit
:si
move /Y *.csv D:\Externos_Temp
cd /D D:\Externos_Temp
ftp -i -s:D:\script.txt
move /Y *.csv D:\Externos_Final
Being script.txt

Code:
open www.some_host.org 2100
some_username
some_password
ascii
mput *.csv
bye
DYN_DaTa is offline  
Old 11-29-2005, 10:23 AM   #7
Posse Member
Ultimate Scripter
ioFTPD Administrator
 
Join Date: Dec 2002
Posts: 2,022
Default

You should use:
cd /D D:\
just to make sure you end up in the root directory of the D drive.
(launching the .bat from a subdir of D:\ will not work correctly...)
Mouton is offline  
Closed Thread
Create a free account to browse our forums without ads



Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -5. The time now is 11:26 AM.