Batch Files (trying to get a simple FTP script to work)

Status
Not open for further replies.

Vormund

Daemon Poster
Messages
1,178
Location
USA
I'm pretty newb with this all (batch files--never needed to use it much!), but:

file: get.bat
ftp -s:get.txt server

file: get.txt
userid
password
cmd #1
cmd #2
etc...

The above *works*, but the following doesn't (all in one file instead):

file: get.bat
ftp server
userid
password
cmd #1
cmd #2
etc...

I'm sure it's something simple, but not enough so as I could get an answer out of Google.

Any help is appreciated,
thanks!
 
That's because each line in a batch file needs to be a command.

your userid and password aren't commands, thus they aren't processed. If you wanted to accomplish this task without using that file.txt, you would be better off using a vb script that initiates a shell.

It looks like you have what you need in your file.txt though, since that seems to be the reason it's included in the ftp program.

Is there a reason you'd rather not have the auth info and commands in a text file?
 
Hi & thanks for the answer!

Nope--I'm just new to using a batch file. I was trying to write a simple program using AutoIt--syncronize my favorites with an easily parsable page on a ftp server--but AutoIt lacks FTP support for now.

I've run into more trouble since using the FTP batch file, so I think I'll have to find another way of doing it.

Thanks!
 
I just looked around AutoIT, and loved it. If you really want, you can use autoIT to automate the task of launching some ftp program (WinSCP?), log into the ftp server, select the file to back up and send it.
 
Well... all I was really trying to do, is have a program run when Internet Explorer (or other browsers--once this is working, lol) is run, check which computer last updated the bookmarks, and syncronize if need be... and in doing that, I was aiming for a background application that nobody would ever notice:) It's just dumb IE, hah, there are plugins for almost every other browser for this!:x

AutoIt is very nice, for the simple things!

thanks again!
 
You can do this in perl and make it very small and keep it invisable. Can be a scheduled task or something you run, ie loginscript...

good luck
 
Hi,

Dont know if i am on the right end of the stick here, but....

I have written a VBS that copys the favourites of the currently logged on user to a specified location. This stores them in any location you chose, network drive etc etc etc..

This file basically deletes the users favourites folder that is stored on the "network drive" then copys over the new "fresh" version from the c:\ drive every time that (or any other user logs in).
Basically meaning they have an upto date back up of their favourites stored on a network drive. We do this for all users on site so we can restore there favourites after we clone/rebuild or replace a pc for them.

It also means no matter where they are on site they have access to the favourites that are normally located on there local machine and as we store them on a netowrk drive we give them sftp access to the drive they can access them from home/anywhere if required aswell...
If you have sftp'd to a location and mapped that location as a drive, you could use this script to copy the favourites folder from the c:\ drvie to that specified location everytime IE launches (if you shedual it to) or at start up. The user would be unaware of this script running as it runs in silent mode and is currently set to not throw back errors even if it fails or ****s up. (ill add in a REM allowing you to turn this on or off) it runs in under a second on every machine i have tested it on and it completley undetectable to the user.


If i have understood what you want let me know and ill post the script for you.. if i have got it wrong sorry for wasting everybody's time..

Cheers
 
o_O That sounds perfect -- so please do post/PM/e-mail it (which ever is easiest to you!), I'd greatly appreciate it.

thank you,
--Xula
 
im not sure this is exactly what you want but ill send it over to you anyway.

This code does exactly what is says in my previous post, but i had a little more time today and read yours again and i think you want something a little more complex.

This code will do the following.

When a user logs on it copys the favourites folder from the local machine and stores them in a location (in this case the N:\ drive) As the N:\ drive is a users person private space on a network that drive can not be accessed by other users. There for ehte code only searches of rthe computer name for example "TheElise" it then stores the favourites on the users N:\ drive as "Favourites TheElise" . If an onther users logs into that same machine, the script will copy their favourites from the local machine to their N:\ drive which is not accessable to any other user to they to will have a folder called "Favourites TheElise" on there N:\ drive.

So here you hit a lsight problem. If you are storing the folders in the same central directory then the script will look at the computer name....for example "TheElise" and look for a folder called "Favourites TheElise" and delete it then re-write it with the ewer version. This is not good if stored on a cetral location because if you logged on with 10.000 favourites on the pc "TheElise" then it would store them for you... if i was to logonto the same pc 10 minutes later it would delete your favourites and replace them with mine. You would ideally need each individual user to have there own private space to store the favourites so they dont get overwitten by the next person.

Or you could ammend thescript slightly and have it insert the user name of the user as well as the computer name so it says

"Favourites John TheElise"
"Favourites Mark TheElise"

That way you know what pc they have been on and you have a copy of there favourites. However by doing this you run the risk of storing millions of folders that are empty if they log into more than one pc you will get multiple entires. such as...

"Favourites John TheElise"
Favourites John BedComp"
"Favourites John LivingComp"
Favourites John KitchenComp"
"Favourites Mark TheElise"
Favourites Mark BedComp"
etc
etc
etc
etc

You see the potential problem here is run on a netowrk as large as ours. Hence the reasson we keep it to compname only on a centrally located private drive.

If you want me to re-write this with the username lookup added ill happily do so, or if the users N:\ drive is private and youll be storing them there then you will have no problem. If you want to create a fodler on the X:\ drive and store everyones favourites there you must ensure that first of all everyone who logs onto the pc has the X:\ drive mapped by default and you will require the users names to be entered other wise the script will keep deleteing previous versions. (this is not an error its designed that way). Also as the script is being run with that users privelages you must ensure they have full read/write access to the drive you are copying the favoutires to. For example the drive would probably be visible in the my computer folder which may lead some users to look in there. Unless you somehow disable it from showing but still have it mapped? then that way they woudnt be able to see the drive or even know it was there but the script would disregard that and look for the X:\ drive and find it as it knows it is there.

Sorry for my spelling i wrote this in about 5 seconds... ;)

let me know what you want me to do?
 
AutoIt does have FTP support. Make sure you ahve the latest version...3.1.1

Under Network Functions in the help file is the command InetGet. There is even more support for the networking in the newest beta version. Readup on the InetGet function in the help file.

-Aaron
 
Status
Not open for further replies.
Back
Top Bottom