I have to upload the same files about once a week, after I change them...I
want to know how to tell the ftp exe program of mine (in Windows) to receive
a text document of the commands, and follow them...can you help?
You posted this question to a *BASIC* newsgroup for *DOS* so I give you an
answer for QuickBASIC (QBASIC.EXE already works fine) here:
' Perform an FTP call in BASIC
INPUT "Host name"; h$
INPUT "User name"; u$
PRINT "Password";
COLOR 0, 0 ' use hidden input. You can write your own more luxurious SUB
routine of course... :-)
INPUT p$
COLOR 7, 0
INPUT "Local directory"; ld$
INPUT "Remote directory"; rd$
INPUT "Remote file name"; rf$
tp$ = ENVIRON$("TEMP")
IF tp$ = "" THEN
PRINT "Make sure that your TEMP environment variable has been"
PRINT "set. Add a line SET TEMP=C:\TEMP to your AUTOEXEC.BAT"
SYSTEM
END IF
IF RIGHT$(tp$, 1) <> "\" THEN
tp$ = tp$ + "\"
END IF
' Create an *unique* temporary file name, so this program can
' simultaneously run multiple times without conflicts
' See http://dreael.catty.ch/Deutsch/BASIC-Knowhow-Ecke/EinbettungBSY.html
for more details
tp$ = tp$ + "~"
FOR I% = 1 TO 3
tp$ = tp$ + CHR$(65 + CINT(INT(26! * RND)))
NEXT I%
tp$ = tp$ + MID$(TIME$, 4, 2) + RIGHT$(TIME$, 2) + ".TMP"
' create a file with FTP commands
OPEN tp$ FOR OUTPUT AS 1
PRINT #1, "user "; u$; " "; p$
PRINT #1, "bin" ' You also can use "asc" instead "bin" for text files
PRINT #1, "cd "; rd$
PRINT #1, "lcd "; ld$
PRINT #1, "get "; rf$
PRINT #1, "bye"
CLOSE 1
' Execute FTP command: This works like in UNIX and Linux :-)
SHELL "ftp -n " + h$ + " <" + tp$
' delete temporary file
KILL tp$
END
I hope this satisfies you. :-) If you intend to write a .BAT file, please
post your question to the news:alt.msdos.batch newsgroup.
Andreas
> PRINT #1, "get "; rf$
Use PRINT#1, "put" for transfer away instead of "get".
Andreas
Create a text file with this in it:
open ftp.site.com
username
[note it does not accept a password from a file]
[you can write your upload commands here]
save the file as, for example, ftp.txt; to save some typing time, create
a batch file and write this:
ftp.exe<ftp.txt
save the batch file as weekftp.bat and run it anytime you want.
Michael