Sync to server

Advertisement

Steve2106
Guest

Sync to server

Hi There,

I have my script working sort of.

I want to use a file filter to upload files to remote server.

Below is my script but it reports "nothing to syncronize"

option batch on
option confirm off
open CarHireBackup
option transfer binary
get C:\StevesStuff\CarHire14112012\*.Dat /testremote/*.Dat
synchronize remote C:\StevesStuff\CarHire14112012\*.Dat testremote\*.Dat
exit

What is wrong with this script?

I appreciate your help.

Best Regards,

Steve

Reply with quote

Advertisement

gman804
Joined:
Posts:
6
Location:
NJ

re: Sync to server

Just an fyi - i always use a full path and put any directory with a space in it in quotes e.g. "c:\Documents and Settings\" or "/cygdrive/c/Documents and Settings/"

your command, "get C:\StevesStuff\CarHire14112012\*.Dat /testremote/*.Dat", should be "get </remote location/file> [local directory\renamefile.renameext]"
so your line should be "get /testremote/*.Dat C:\StevesStuff\CarHire14112012\"
I removed the *.dat from the end of C:\StevesStuff\CarHire14112012\ because you're not renaming files.

your command, "synchronize remote C:\StevesStuff\CarHire14112012\*.Dat testremote\*.Dat", should be
"synchronize remote C:\StevesStuff\CarHire14112012\ /testremote/ -filemask="*.Dat"
more than one file extension can be separated by a "; " e.g. "*.Dat; *.txt"
make sure that it's .Dat that you want and not .dat bc it may be case-sensitive, also unix uses a forward-slash, "/"

Reply with quote

Steve2106
Joined:
Posts:
5
Location:
Bromley, UK

Hi There,

I cannot get this to work.
If I explain what I want to do maybe someone can show me the way.

From a directory on my PC I want to get all files with a .Dat extention and upload them to a backup directory on a server.

Would anyone know the script code to do that.

Below is the script I am trying to use and it nearly works:

option batch on
option confirm off
open CarHireBackup
option transfer binary
get C:\StevesStuff\CarHire14112012\*.Dat /CarHireBackUp/
synchronize remote C:\StevesStuff\CarHire14112012\ /CarHireBackUp/ -filemask="*.Dat"
exit

I don't want to syncronise just upload.

Thanks for your help.

Best Regards,

Steve.

Reply with quote

Steve2106
Joined:
Posts:
5
Location:
Bromley, UK

Hi There,

I have tried a couple of other things and they look more successful but I still do not see the file.
You can see my log & script code below.

This is the log returned:
. 2012-11-21 14:38:58.655 Using FTP protocol.
. 2012-11-21 14:38:58.655 Doing startup conversation with host.
> 2012-11-21 14:38:58.655 PWD
< 2012-11-21 14:38:58.781 257 "/StWilson" is current directory.
. 2012-11-21 14:38:58.781 Changing directory to "CarHireBackUp".
> 2012-11-21 14:38:58.781 CWD CarHireBackUp
< 2012-11-21 14:38:58.908 250 CWD command successful.
. 2012-11-21 14:38:58.908 Getting current directory name.
> 2012-11-21 14:38:58.908 PWD
< 2012-11-21 14:38:59.038 257 "/StWilson/CarHireBackUp" is current directory.
. 2012-11-21 14:38:59.038 Startup conversation with host finished.
< 2012-11-21 14:38:59.038 Script: Active session: [1] CarHireBackup
> 2012-11-21 14:38:59.038 Script: option transfer binary
< 2012-11-21 14:38:59.038 Script: transfer binary
> 2012-11-21 14:38:59.039 Script: Put C:\StevesStuff\CarHire14112012\BrokenWindow.TXT \CarHireBackUp\
. 2012-11-21 14:38:59.039 Copying 1 files/directories to remote directory "/StWilson/CarHireBackUp"
. 2012-11-21 14:38:59.039 PrTime: Yes; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: 0100; Resume: S (102400); CalcS: No; Mask: \CarHireBackUp\
. 2012-11-21 14:38:59.039 TM: B; ClAr: No; CPS: 0; InclM:
. 2012-11-21 14:38:59.039 AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
. 2012-11-21 14:38:59.039 File: "C:\StevesStuff\CarHire14112012\BrokenWindow.TXT"
. 2012-11-21 14:38:59.042 Copying "C:\StevesStuff\CarHire14112012\BrokenWindow.TXT" to remote directory started.
. 2012-11-21 14:38:59.042 Binary transfer mode selected.
. 2012-11-21 14:38:59.043 Starting upload of C:\StevesStuff\CarHire14112012\BrokenWindow.TXT
> 2012-11-21 14:38:59.043 TYPE A
< 2012-11-21 14:38:59.175 200 Type set to A.
> 2012-11-21 14:38:59.176 PASV
< 2012-11-21 14:38:59.312 227 Entering Passive Mode (174,36,218,226,19,156).
> 2012-11-21 14:38:59.312 LIST
< 2012-11-21 14:38:59.579 125 Data connection already open; Transfer starting.
. 2012-11-21 14:38:59.581 11-21-12 06:53AM 2048 CarHireBackUp
. 2012-11-21 14:38:59.581 11-16-12 07:55AM <DIR> testremote
< 2012-11-21 14:38:59.914 226 Transfer complete.
> 2012-11-21 14:38:59.915 TYPE I
< 2012-11-21 14:39:00.038 200 Type set to I.
> 2012-11-21 14:39:00.038 PASV
< 2012-11-21 14:39:00.166 227 Entering Passive Mode (174,36,218,226,19,157).
> 2012-11-21 14:39:00.166 STOR CarHireBackUp
< 2012-11-21 14:39:00.442 125 Data connection already open; Transfer starting.
< 2012-11-21 14:39:00.770 226 Transfer complete.
. 2012-11-21 14:39:00.770 Upload successful
> 2012-11-21 14:39:00.770 Script: exit
. 2012-11-21 14:39:00.770 Script: Exit code: 0
. 2012-11-21 14:39:00.773 Disconnected from server

This is my Script:
option batch on
option confirm off
open CarHireBackup
option transfer binary
Put C:\StevesStuff\CarHire14112012\BrokenWindow.TXT \CarHireBackUp\
exit


I would appreciate if anyone can see why the file is not showing.

Best Regards,

Steve.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,442
Location:
Prague, Czechia

Where do you want your files to end up? In /StWilson/CarHireBackUp?

option batch on
option confirm off
open CarHireBackup
option transfer binary
put C:\StevesStuff\CarHire14112012\BrokenWindow.TXT /StWilson/CarHireBackUp
ls /StWilson/CarHireBackUp
exit

Note the "ls" at the end will list the target directory, so that we can see, if the file is there or not.

Reply with quote

Steve2106
Joined:
Posts:
5
Location:
Bromley, UK

Hi prikryl,
Thanks for your reply.

I have got this working now. Thankyou.

I have one other important request.

How do I add the date and time to the file names?
This is because I want to create the backup files but not overwrite what is already there.

So I need BrokenWindow.TXT to be BrokenWindow20121122_1450.TXT etc.

Can that be done?

Thanks again for your help, I really appreciate it.


Best Regards,

Steve.

Reply with quote

Steve2106
Joined:
Posts:
5
Location:
Bromley, UK

Hi prikryl,

Thanks for the quick reply.

Can the WinSCP script be run in a .bat file?

I have some code that appends the date & time to files for a different purpose but I could try to use that.

I am not sure how to code the script that WinSCP needs in a .bat file.

Do you have any pointers?

Best Regards,

Steve.

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum