upload a file to a ftp server from command line [Solved]

Under development: PCMCIA, wireless, etc.
Message
Author
User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

upload a file to a ftp server from command line [Solved]

#1 Post by Lobster »

Solution
sh-3.00# ftpput -v -u myusername -p mypassword webpages.charter.net / test.html

Problem (see above for solution)

I have been trying to use one of the busybox commands
to upload a file to a ftp server from a command line
(I can download OK)

this is my input

Code: Select all

#ftpput -v -u username -p password -P 21 ftp.server.com test3 test3
and this is what I get

Code: Select all

Connecting to ftp.server.com
ftpput: cmd (null)(null)
ftpput: cmd USER username
ftpput: cmd PASS password
ftpput: cmd TYPE I(null)
ftpput: cmd PASV(null)
ftpput: cmd CWD test3
ftpput: CWD error: Can't change directory to test3: No such file or directory
a new busybox is available
http://www.busybox.net/

doing a forum search and google search others seem to have difficulties too

Is there some simple thing I am missing?
. . . any other way of uploading from command line perhaps using curl?
Last edited by Lobster on Thu 07 Jun 2007, 09:08, edited 1 time in total.
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

User avatar
alienjeff
Posts: 2265
Joined: Sat 08 Jul 2006, 20:19
Location: Winsted, CT - USA

#2 Post by alienjeff »

I, too, have experienced frustration with the stripped-down and sometimes kludge-versions of apps within Busybox. This frustration is especially painful having used the "real" versions of such apps in full-sized *nix distros. There is relief to the ftp woes, Ed.

My own favorite ftp tool is lftp, a superb, full-featured cli ftp app strongly suggested to me by my guru-by-marriage, ubergeek nephew-in-law. Downloading the source and compiling went well, too. I now happily shun gftp like the plague and fiddle with scripts to automate lftp tasks.

Some related links:

an excellent lftp tutorial

lftp mail threads

To fully appreciate the power of lftp, patiently and methodically going through the tutorial linked above is advised. Set aside a wee bit of time as it's well worth it! To do otherwise, you'd be cheating yourself. lftp makes fast and efficient work of my own website maintenance.

-aj
[size=84][i]hangout:[/i] ##b0rked on irc.freenode.net
[i]diversion:[/i] [url]http://alienjeff.net[/url] - visit The Fringe
[i]quote:[/i] "The foundation of authority is based upon the consent of the people." - Thomas Hooker[/size]

User avatar
HairyWill
Posts: 2928
Joined: Fri 26 May 2006, 23:29
Location: Southampton, UK

#3 Post by HairyWill »

@Lobster
As you mentioned curl, yes there is a way using curl. Gekko posted curlftpfs, the second dotpup here
http://murga-linux.com/puppy/viewtopic. ... 4776#94776
Just ignore all the GUI stuff he gives an example of a command to mount a remote ftp site as a local directory.

@AlienJeff
lftp looks very interesting I think I'll have to investigate that further.
Will
contribute: [url=http://www.puppylinux.org]community website[/url], [url=http://tinyurl.com/6c3nm6]screenshots[/url], [url=http://tinyurl.com/6j2gbz]puplets[/url], [url=http://tinyurl.com/57gykn]wiki[/url], [url=http://tinyurl.com/5dgr83]rss[/url]

User avatar
trapster
Posts: 2117
Joined: Mon 28 Nov 2005, 23:14
Location: Maine, USA
Contact:

#4 Post by trapster »

I use curl with the following:

Code: Select all

curl -T /filetouploadlocation/file.xxx ftp.wherever.com/directory/ -u user@website.com:password
trapster
Maine, USA

Asus eeepc 1005HA PU1X-BK
Frugal install: Slacko
Currently using full install: DebianDog

User avatar
alienjeff
Posts: 2265
Joined: Sat 08 Jul 2006, 20:19
Location: Winsted, CT - USA

#5 Post by alienjeff »

Just as an example of a typical lftp session here after making a new webpage on my desktop computer and wanting to update the remote server hosting my site:

Code: Select all

Hit F4 key (my personal hotkey to "open console")
cd /root/ghttpd/htdocs (get into the proper directory)
lftp mywebsite (calls simple mywebsite logon script)
mirror -Rn (compares local/remote dir contents, updates remote as necessary)
bye (closes lftp session)
This could (and will) be automated further when I write a simple bash script, but you get the idea.

June 15, 2007 edit: wove in directory change in above cli sequence to script file; to wit:

Code: Select all

F4
lftp mywebsite
mirror -Rn
bye
Now to figure out how to script the mirror command and "auto-bye" when mirror is completed. Off to O'Reilly's "Learning the bash shell" with the ultimate goal of hitting one hotkey to update the website.

-aj
Last edited by alienjeff on Fri 15 Jun 2007, 09:35, edited 2 times in total.
[size=84][i]hangout:[/i] ##b0rked on irc.freenode.net
[i]diversion:[/i] [url]http://alienjeff.net[/url] - visit The Fringe
[i]quote:[/i] "The foundation of authority is based upon the consent of the people." - Thomas Hooker[/size]

User avatar
trapster
Posts: 2117
Joined: Mon 28 Nov 2005, 23:14
Location: Maine, USA
Contact:

#6 Post by trapster »

I just tried the ftpput and it seems to work for me with:

Code: Select all

sh-3.00# ftpput -v -u name@server.com -p password ftp.server.com /web/ stats
Connecting to ftp.nameofserver.com:21
ftpput: cmd (null)(null)
ftpput: cmd USER name@server.com
ftpput: cmd PASS password
ftpput: cmd TYPE I(null)
ftpput: cmd PASV(null)
ftpput: cmd CWD /web/
ftpput: cmd ALLO 1389(null)
ftpput: cmd STOR stats
ftpput: cmd (null)(null)
ftpput: cmd QUIT(null)
sh-3.00#
It seems you also need to tell it what directory you want to upload the file to
Last edited by trapster on Tue 05 Jun 2007, 13:54, edited 2 times in total.
trapster
Maine, USA

Asus eeepc 1005HA PU1X-BK
Frugal install: Slacko
Currently using full install: DebianDog

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#7 Post by Lobster »

:) Thanks guys already making progress (managed to upload a zero byte file) - well it is my idea of progress

these are the last few lines of code - and it is the last one that is opening the file(but not completing the transfer . . .

Code: Select all

ftpput: cmd TYPE I(null)
ftpput: cmd PASV(null)
ftpput: cmd CWD /www/ap2/
ftpput: cmd ALLO 11882(null)
ftpput: cmd STOR test3
ftpput: cmd (null)(null)
I am trying another server and persevere a little more with the busy box command. Maybe we need a newer version of BusyBox BUT that would be a major upgrade for Puppy I believe?

One potential of this command is to store configuration details with a Puppy server (for thoose without tin foil hats)

DSL I believe offer this option . . .

Update

OK I tried the Curl command on two servers (it seemed to be working) then it became slower and slower and failed
Again it created a 0 byte file on the server
Last edited by Lobster on Tue 05 Jun 2007, 09:21, edited 2 times in total.
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

User avatar
Gekko
Posts: 443
Joined: Sat 22 Jul 2006, 09:57
Location: Sydney, New South Wales

#8 Post by Gekko »

Why would you bother with something that obviously doesnt work? Just get lftp >_>. If you need me to package, I'll do that too. I also fail to see how this is "cutting edge."

User avatar
Gekko
Posts: 443
Joined: Sat 22 Jul 2006, 09:57
Location: Sydney, New South Wales

#9 Post by Gekko »

http://www.murga-linux.com/puppy/viewtopic.php?p=120701
Theres your .pet Lobster, now you have no excuse.

kirk
Posts: 1553
Joined: Fri 11 Nov 2005, 19:04
Location: florida

#10 Post by kirk »

I use wput to do that. Here's the man page:

http://wput.sourceforge.net/wput.1.html


And I'll attach a binary.
Attachments
wput.gz
(31.93 KiB) Downloaded 444 times

User avatar
alienjeff
Posts: 2265
Joined: Sat 08 Jul 2006, 20:19
Location: Winsted, CT - USA

#11 Post by alienjeff »

Just on a whim, I tried ftpput and after arguing with either ftpput or charter.net's syntax, a successful transfer was made. Here's the syntax I used:

Code: Select all

sh-3.00# ftpput -v -u myusername -p mypassword webpages.charter.net / test.html
Makes me appreciate lftp that much more.

</shameless_plug>

-aj
[size=84][i]hangout:[/i] ##b0rked on irc.freenode.net
[i]diversion:[/i] [url]http://alienjeff.net[/url] - visit The Fringe
[i]quote:[/i] "The foundation of authority is based upon the consent of the people." - Thomas Hooker[/size]

User avatar
Gekko
Posts: 443
Joined: Sat 22 Jul 2006, 09:57
Location: Sydney, New South Wales

#12 Post by Gekko »

Wow, that sucks.

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#13 Post by Lobster »

thanks guys

thanks Kirk for that small util
got wput working using this info
http://en.wikipedia.org/wiki/Wput#Examples

I have looked at wput before - this time it worked
it seemed to hang about - may now look at the options to force a quick shutdown

:)
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#14 Post by Lobster »

OK that works :)
ftpput -v -u myusername -p mypassword webpages.charter.net / test.html
. . . and it was fast and used Puppys existing code
(so it is my preferred solution)
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#15 Post by zigbert »

Does ftpput allows to transfer a directory with its files, or is it restricted to only work with one file?

User avatar
alienjeff
Posts: 2265
Joined: Sat 08 Jul 2006, 20:19
Location: Winsted, CT - USA

#16 Post by alienjeff »

HINT #1: ftpput --help
HINT #2: http://busybox.net/about.html
HINT #3: "Nothing ventured, nothing gained"

Reality check: consider core apps or lftp

-aj
[size=84][i]hangout:[/i] ##b0rked on irc.freenode.net
[i]diversion:[/i] [url]http://alienjeff.net[/url] - visit The Fringe
[i]quote:[/i] "The foundation of authority is based upon the consent of the people." - Thomas Hooker[/size]

User avatar
HairyWill
Posts: 2928
Joined: Fri 26 May 2006, 23:29
Location: Southampton, UK

#17 Post by HairyWill »

zigbert wrote:Does ftpput allows to transfer a directory with its files, or is it restricted to only work with one file?
I don't think ftpput supports directories but wput does. This is what I was looking for when I wrote pftpcopy. I could probably replace much of what I did with a thin wrapper around wput. It evens supports resuming and not overwriting newer files.
Will
contribute: [url=http://www.puppylinux.org]community website[/url], [url=http://tinyurl.com/6c3nm6]screenshots[/url], [url=http://tinyurl.com/6j2gbz]puplets[/url], [url=http://tinyurl.com/57gykn]wiki[/url], [url=http://tinyurl.com/5dgr83]rss[/url]

User avatar
Gekko
Posts: 443
Joined: Sat 22 Jul 2006, 09:57
Location: Sydney, New South Wales

#18 Post by Gekko »

Lftp is just nice that you don't have to type a million things to get results and has many features in a small size.

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#19 Post by zigbert »

Thanks for tips

This is for Pbackup, and I don't yet have ftp-access, so Im just collecting info. Pbackup is at the moment 22kb packed, and I want to keep as small as possible. That's why I intend to use Puppy builtin packages only. If I understand it right, ftpput and curl is the only builtins that does the ftp-job ???

HairyWill has made an aproach for ftp-sync. I will not compete with his work which seems to be rather complex. I thought of a damn easy transfer of a selection of backupfiles to the server.

Sigmund

User avatar
Gekko
Posts: 443
Joined: Sat 22 Jul 2006, 09:57
Location: Sydney, New South Wales

#20 Post by Gekko »

if the file is compressed into a .tar.* it could be easily scripted into a GUI. All you need is the username, password, server address, port and path to file. Then it is pretty much complete. Do you want me to write a bash script you can use with the variables all set up?

Post Reply