lets say I am working on index.php and configuring style.css that is on css folder. can I transfer both files using comand line to the server using one line?
You can upload a files by creating an ftp command script file (e.g. ftp.txt) with the content:
(username)
(password)
cd /folder-on-server
binary
put c:\myfolder\myfile.jpg
put c:\myfolder\style.css
Then on the command line
ftp -s:ftp.txt ftp.example.com
Based on: http://wiki.tekkies.co.uk/General_Technical#FTP_using_xp_cmdshell_-_sql2k
Related
I'm writing a *.bat file (Windows) in which I use FTP commands to get remote files back on a local machine. The remote directory includes a archive subdirectory in which I want to move the files once they are downloaded on the local machine.
My script in the *.bat file:
ftp -v -i -s:GET_FILES_FTP.txt
My script in GET_FILES_FTP.txt:
open example.com
username
password
lcd S:\
lcd repository/files
mget *.txt
rename *.txt archive/
disconnect
bye
Note that hostname, username and password are not those I use for real!
The TXT files are downloaded properly on the local machine.
The problem is that rename *.txt archive/ is not interpreted and the files do not move to the archive file. I the command window, I get an error message:
directory not found.
I can't find extra information better than this doc.
Any idea on how to move the files?
The rename command of the Windows ftp.exe does not support wildcards.
You would have to dynamically generate a script file based on a list of downloaded files with a separate rename command for each file.
Or use a different command-line FTP client that supports wildcards when renaming/moving.
For example with WinSCP scripting the batch file would be like:
winscp.com /log=winscp.log /command ^
"open ftp://username:password#example.com" ^
"lcd S:\" ^
"lcd repository\files" ^
"get *.txt" ^
"mv *.txt archive/" ^
"exit"
For details see:
mv command
Converting Windows FTP script to WinSCP FTP script
(I'm the author of WinSCP)
Using FTP commands I want to upload a large file once and then copy that file to many directories on the remote FTP server. All the copy commands seems to relate to copying from local to remote or the other way around.
Is there an FTP command to copy remote to remote?
are you trying to move the file? if yes, you can do it using rename command to move the file, as for copy i guess you still have to do the the get,send from local-remote way.
as for move command should be something like this
rename /oldpath/file2move.txt /newpath/file2move.txt
Basically just rename your file path that is infront of the file that you wish to move.
As far as I know, there is no such command available in FTP protocol. There are some extensions to SFTP protocol to do this (and, having SSH access, you can issue cp commands), but SFTP is not an FTP.
Hi I want to LOOP through files on FTP and copy one by one. Every thing is fine with FTP connection and accessing folders.
My question is How can loop through all files on FTP. It looks like there is no "For" type of functionality available to access FTP files because each line is considered as complete command.
open MyServerName 21
MyUserName
MyPassword
lcd E:\LocalDirectory
cd /FTPDirectory/upload
I WANT TO LOOP THROGH ALL FILES AND COPY ONE BY ONE TO LOCAL DIRECTORY
disconnect
bye
Why i want to loop through all files in FTP is, I want to copy only those files which are not locked and available for copy.
Use a different FTP client: wget.
With the -m option (for --mirror), use the following in a script
cd mylocaldirectory
wget -m ftp://username:password#hostname/theremotedirectory
I am attempting to create a dynamic list of files available in an ftp directory. I assume wget can help with this but I'm not really sure how...so my question is:
What is the syntax for retrieving file names from an ftp directory using wget?
Just execute
wget --no-remove-listing ftp://myftpserver/ftpdirectory/
This will generate two files: .listing (this is what you are looking for) and index.html which is the html version of the listing file.
i want to automate the task of uploading of a file at FTP site "uploads.google.com"
how can i achive this
please see here for example
One of the example is depicted as follows :
Prepare a file (say ftp_cmd.txt)with all the ftp commands to upload the files to our specific site
as below:
binary
cd
mput file.*
bye
Now create a batch file with the following content:
ftp -i -v -s:
ex: ftp -i -v -s:ftp_cmd.txt updates.google.com
Now, when you execute this batch file, it will put all files with format file.* to the specified directory.