I need help with IT homework aswell :(

Congax

Fledgling Freddie
Joined
Aug 18, 2004
Messages
3,231
Quick & simple: how to make a batch file in windows that does automatic login & upload to an FTP server? So say for exemple, I click the batch file, it logs me in on server and uploads some folder and files in it (ofc, name of the folder etc are in batch file)

I got it covered in Linux but can't do it in Windows. Well, the logon works in Windows, but that's about it. :/

Code:
@echo off
SET TMP=tmpScript.bat
SET URL=zesib1
SET USR=attuned
SET PAS=XXXXX

echo open %URL%>%TMP%
echo %USR%>>%TMP%
echo %PAS%>>%TMP%
echo put %1>>%TMP%
echo quit>>%TMP%
ftp -s:%TMP%
rm %TMP%

I give great rep to whoever can help whatsoever! ;>
 

yaruar

Can't get enough of FH
Joined
Dec 22, 2003
Messages
2,617
Congax said:
Quick & simple: how to make a batch file in windows that does automatic login & upload to an FTP server? So say for exemple, I click the batch file, it logs me in on server and uploads some folder and files in it (ofc, name of the folder etc are in batch file)

I got it covered in Linux but can't do it in Windows. Well, the logon works in Windows, but that's about it. :/

Code:
@echo off
SET TMP=tmpScript.bat
SET URL=zesib1
SET USR=attuned
SET PAS=XXXXX

echo open %URL%>%TMP%
echo %USR%>>%TMP%
echo %PAS%>>%TMP%
echo put %1>>%TMP%
echo quit>>%TMP%
ftp -s:%TMP%
rm %TMP%

I give great rep to whoever can help whatsoever! ;>

Im assuming you aren't actually using %tmp% in the batch script as that should be a preconfigured environment variable.....
 

Congax

Fledgling Freddie
Joined
Aug 18, 2004
Messages
3,231
What? No, I'm using it in the batch script :/ But all these lines work, it's just that whenever I try to add the lines where he picks up the files and uploads it that it doesn't work :(

f.e.

@ECHO OFF
SET TMP=tmpScript1.bat
SET URL=zesib1
SET USR=attuned
SET PAS=XXXX

echo open %URL%>%TMP%
echo %USR% >> %TMP%
echo %PAS% >> %TMP%
echo mkdir Test >> %TMP%
echo cd Test >> %TMP%
echo lcd Test >> %TMP%
echo mput * >> %TMP%
echo mkdir Tester >> %TMP%
echo cd Tester >> %TMP%
echo lcd Tester >> %TMP>
echo mput * >> %TMP%
echo quit >> %TMP%
ftp -s:%TMP%
rm %TMP%
 

Alan

Fledgling Freddie
Joined
Aug 3, 2004
Messages
3,972
Code:
@ECHO OFF
SET TMP=tmpScript1.bat
SET URL=zesib1
SET USR=attuned
SET PAS=XXXX

echo open %URL%>%TMP%
echo %USR% >> %TMP%
echo %PAS% >> %TMP%
echo mkdir Test >> %TMP%
echo cd Test >> %TMP%
echo lcd Test >> %TMP%
echo mput * >> %TMP%
echo mkdir Tester >> %TMP%
echo cd Tester >> %TMP%
echo lcd Tester >> %TMP[B][I]>[/I][/B] [i]<--- change here[/i]
echo mput * >> %TMP%
echo quit >> %TMP%
ftp -s:%TMP%
rm %TMP%

The > thing should be a % and like said above, dont use TMP, its a variable used by windows :)
 

Congax

Fledgling Freddie
Joined
Aug 18, 2004
Messages
3,231
But the TMP works perfect, a temporary file gets created which stores the thingies, but okay, I'll try again :p
 

Alan

Fledgling Freddie
Joined
Aug 3, 2004
Messages
3,972
Congax said:
But the TMP works perfect, a temporary file gets created which stores the thingies, but okay, I'll try again :p


yeah and then another app unrelated to yours wants to create a temporary file so it queries the system environment variable called TMP to find out where it should stick it - which you have now overwritten with something else.

There are other applications that run on computers :)

Infact, you could make use of this to stuff YOUR temporary file in the correct place rather than the default directory - but thats probably going overboard.

Code:
@ECHO OFF
SET inputfile=%TMP%\ftpinput.txt
...
...
ftp -s:%inputfile%
rm %inputfile%
 

Congax

Fledgling Freddie
Joined
Aug 18, 2004
Messages
3,231
Now you mention it, it does indeed not do much after the file gets created :p
 

Congax

Fledgling Freddie
Joined
Aug 18, 2004
Messages
3,231
Code:
@echo off

:: Passwoord?
IF "%1"=="" GOTO Syntax

:: Temp file
> scriptdata.txt ECHO USER attuned
>> scriptdata.txt ECHO %1
>> scriptdata.txt echo bin
>> scriptdata.txt echo hash
>> scriptdata.txt echo cd public_html
>> scriptdata.txt echo lcd website
>> scriptdata.txt echo mput *
>> scriptdata.txt echo lcd pics
>> scriptdata.txt echo mkdir pics
>> scriptdata.txt echo mput *
>> scriptdata.txt echo bye


ftp -s:scriptdata.txt zesib1
del scriptdata.txt
GOTO End

:Syntax
ECHO Usage: %0 password

:End

How about this? :D
 

Alan

Fledgling Freddie
Joined
Aug 3, 2004
Messages
3,972
Congax said:
Code:
@echo off

:: Passwoord?
IF "%1"=="" GOTO Syntax

:: Temp file
> scriptdata.txt ECHO USER attuned
>> scriptdata.txt ECHO %1
>> scriptdata.txt echo bin
>> scriptdata.txt echo hash
>> scriptdata.txt echo cd public_html
>> scriptdata.txt echo lcd website
>> scriptdata.txt echo mput *
>> scriptdata.txt echo lcd pics
>> scriptdata.txt echo mkdir pics
>> scriptdata.txt echo mput *
>> scriptdata.txt echo bye


ftp -s:scriptdata.txt zesib1
del scriptdata.txt
GOTO End

:Syntax
ECHO Usage: %0 password

:End

How about this? :D

Much cleaner :)
 

Users who are viewing this thread

Top Bottom