Go Back   FlashFXP Forums > >

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

Closed Thread
 
Thread Tools Rate Thread Display Modes
Old 11-21-2005, 08:23 AM   #1
DYN_DaTa
Senior Member
FlashFXP Scripter
 
Join Date: Jan 2002
Location: Madrid, Spain
Posts: 346
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, 03:25 PM   #2
_panic_
Senior Member
Ultimate Scripter
 
Join Date: Jul 2005
Posts: 153
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, 06:14 AM   #3
DYN_DaTa
Senior Member
FlashFXP Scripter
 
Join Date: Jan 2002
Location: Madrid, Spain
Posts: 346
Default

Thanks .

I'll take a look.
DYN_DaTa is offline  
Old 11-22-2005, 11:32 AM   #4
Mouton
Posse Member
Ultimate Scripter
ioFTPD Administrator
 
Join Date: Dec 2002
Posts: 1,956
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, 03:14 PM   #5
DYN_DaTa
Senior Member
FlashFXP Scripter
 
Join Date: Jan 2002
Location: Madrid, Spain
Posts: 346
Default

Nice one, Mouton, i'll try it. Thanks
DYN_DaTa is offline  
Old 11-28-2005, 02:38 PM   #6
DYN_DaTa
Senior Member
FlashFXP Scripter
 
Join Date: Jan 2002
Location: Madrid, Spain
Posts: 346
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, 11:23 AM   #7
Mouton
Posse Member
Ultimate Scripter
ioFTPD Administrator
 
Join Date: Dec 2002
Posts: 1,956
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

Tags
file, flashfxp, folder, ftp, upload


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

Forum Jump


All times are GMT -5. The time now is 03:47 AM.

Parts of this site powered by vBulletin Mods & Addons from DragonByte Technologies Ltd. (Details)