ftp help needed
Hi,
Currently i need to create a shell script on my gameserver that will have to upload the day's CSS log files to another server...however i have no idea how to do this using ftp, since ftp only takes as arguments the hostname and port of the server in the following fashion.. ftp host port and then drops into interactive mode. how can i make it upload a file named server.log to another ftp server ? |
Hi mewt,
Assuming that you have lftp, the Sophisticated file transfer program, installed, you can write a script for automating the file transfer. So, please do the following and get back if you find any difficulties : - Quote:
Theorist |
I tried doing using lftp but i only ended up being more muddled than before...i am trying to use the following:
lftp -c mput *.log -u user password -p 21 hostname but im getting unknown command --u :S any ideas why ? or what error im doing in the syntax ? |
ok something is working now:
i used lftp <hostname> -u username,password -c mput *.log and lftp logged into the server and dropped me into a command line.. however the transfer of the log files did not start... Mewt |
I also tried using mirror -R to mirror the whole directory to ftp but still says unknown command -c :S
|
Hi mewt,
Alright. So, here is how to create a script to be used with lftp. Do everything step by step. First, open lftp : - Quote:
Quote:
Third, upload all the .log files : - Quote:
Quote:
To run the script just run the following : - Quote:
Theorist |
Thanks a lot! you were really of great help...i still wonder however why the command -c wouldnt work..AFAIK i was doing everything according to the manual of lftp :S
thanks Mewt |
Hi mewt,
You should not just read the man page alone, but also try various possibilities, based on what it says. mput -c wildcard option works very well for me. Try doing it separately, I believe it will work for you too. Anyways, I am glad that you gave it a try. Keep the spirit up! Explore and find ways of doing things yourself. That is the best way of learning. With Regards, Theorist |
Hi Mewt,
Now I understood why -c option did not work for you. Earlier, I was thinking that you were talking about using -c option with mput command. I got it. Firstly, you tried to run Quote:
Quote:
You need to put the command following -c enclosed in double quotes. But the following command Quote:
Instead of -c if you use -e in the above command, it will work. If you read the man page, you will know why is that so. With Regards, Theorist |
i tried the -e function too and still didnt work cos i didnt have the ""...thanks for your help
|
An alternative method using normal ftp:
Code:
ftp -n host << EOF |
Quote:
Even without knowing the lftp command at all, I can tell you that double quotes won't help. The problem is that the shell will expand *.log into the list of files (in your current directory) which happen to have the .log filename extension, before passing everything to lftp. So, lftp will get to see something like: ... -c a.log b.log c.log etc instead of '*.log'. To prevent the shell from interpreting "*.log", you need to put it in SINGLE quotes, not double quotes. It is probably better to enclose the entire FTP command in single quotes. |
Hi timmeke,
Quote:
With Regards, Theorist |
It may work, but it actually does (in FTP):
mput file1.log file2.log file3.log ... not mput *.log This is a subtle difference, since both FTP commands should -in theory- work equally well. You may get into trouble if you have really many .log files with your approach. The single quote approach should always work. |
All times are GMT -5. The time now is 07:15 PM. |