Tux

...making Linux just a little more fun!

How do you format ftp or sftp for transfering files?...

Don Saklad [dsaklad at gnu.org]


Sun, 08 Mar 2009 16:23:26 -0400

How do you format ftp or sftp for transfering files?...


Top    Back


Lew Pitcher [lew.pitcher at digitalfreehold.ca]


Sun, 8 Mar 2009 16:52:23 -0400

On March 8, 2009 16:23:26 Don Saklad wrote:

> How do you format ftp or sftp for transfering files?...

Hi, Don

I don't understand your use of the word "format"

Do you mean format as in "format a file or filesystem", or do you mean it as in "what should it look like"?

Could you perhaps describe the problem you are trying to solve? And why you think ftp or sftp will help?

Realize that both ftp and sftp require a client application on one side, and a server on the other. Are you asking what the client command should look like?

Note also that normally, both ftp and sftp are interactive; the command invocation does not usually define all the file transfer requirements.

-- 
Lew Pitcher
 
Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/   | GPG public key available by request
----------      Slackware - Because I know what I'm doing.          ------


Top    Back


Rick Moen [rick at linuxmafia.com]


Sun, 8 Mar 2009 14:13:09 -0700

Quoting Don Saklad (dsaklad@gnu.org):

> How do you format ftp or sftp for transfering files?...

Why is a raven like a writing desk?

(You should, please, rephrase your question so that its semantic payload is more easily understood.)


Top    Back


Ben Okopnik [ben at linuxmafia.com]


Sun, 8 Mar 2009 18:12:33 -0400

On Sun, Mar 08, 2009 at 02:13:09PM -0700, Rick Moen wrote:

> Quoting Don Saklad (dsaklad@gnu.org):
> 
> > How do you format ftp or sftp for transfering files?...
> 
> Why is a raven like a writing desk?

Neither can be transferred via {s,}ftp?

> (You should, please, rephrase your question so that its semantic payload
> is more easily understood.)

Yes indeed. We'd be happy to help you, Don, once we understand the question.

-- 
* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *


Top    Back


Ben Okopnik [ben at linuxgazette.net]


Sun, 8 Mar 2009 18:28:31 -0400

On Sun, Mar 08, 2009 at 04:52:23PM -0400, Lew Pitcher wrote:

> 
> Note also that normally, both ftp and sftp are interactive; the command 
> invocation does not usually define all the file transfer requirements.

Actually, that part's pretty easy.

ben@Tyr:~$ >FOOBAR
ben@Tyr:~$ echo -e "cd /tmp\nput FOOBAR\n"|sftp ben@localhost
Connecting to localhost...
ben@localhost's password: 
sftp> cd /tmp
sftp> put FOOBAR
Uploading FOOBAR to /tmp/FOOBAR
FOOBAR                                 100%    0     0.0KB/s   00:00    
sftp> 
ben@Tyr:~$ ls /tmp/F*
/tmp/FOOBAR

If I had the password for 'localhost' defined in my ~/.netrc, I wouldn't even have had to stop for that.

-- 
* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *


Top    Back


Lew Pitcher [lew.pitcher at digitalfreehold.ca]


Mon, 9 Mar 2009 10:23:14 -0400

On March 8, 2009 18:28:31 Ben Okopnik wrote:

> On Sun, Mar 08, 2009 at 04:52:23PM -0400, Lew Pitcher wrote:
> > Note also that normally, both ftp and sftp are interactive; the command
> > invocation does not usually define all the file transfer requirements.
>
> Actually, that part's pretty easy.
>
> ```
> ben@Tyr:~$ >FOOBAR
> ben@Tyr:~$ echo -e "cd /tmp\nput FOOBAR\n"|sftp ben@localhost
[snip]

True(ish)

I've used something similar in a couple of my own projects.

The drawback for "preloading" the responses to an interactive stream like this is that neither ftp nor sftp include a way to determine whether or not the commands worked. Had your sftp session not been able to connect to localhost, or not been able to cd to /tmp, the "preloaded" command stream would have failed, but /appeared/ to have worked.

There /are/ (s)ftp clients that support scripting, and scripting languages (like perl and php, for instance) that support (s)ftp, so this potential flaw can be remedied.

OTOH, the OP has yet to explain what he meant, so perhaps we are going down the wrong path. I guess time will tell. :-)

-- 
Lew Pitcher
 
Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/   | GPG public key available by request
----------      Slackware - Because I know what I'm doing.          ------


Top    Back


Ben Okopnik [ben at linuxgazette.net]


Mon, 9 Mar 2009 10:51:28 -0400

On Mon, Mar 09, 2009 at 10:23:14AM -0400, Lew Pitcher wrote:

> On March 8, 2009 18:28:31 Ben Okopnik wrote:
> > On Sun, Mar 08, 2009 at 04:52:23PM -0400, Lew Pitcher wrote:
> > > Note also that normally, both ftp and sftp are interactive; the command
> > > invocation does not usually define all the file transfer requirements.
> >
> > Actually, that part's pretty easy.
> >
> > ```
> > ben@Tyr:~$ >FOOBAR
> > ben@Tyr:~$ echo -e "cd /tmp\nput FOOBAR\n"|sftp ben@localhost
> [snip]
> 
> True(ish)
> 
> I've used something similar in a couple of my own projects.
> 
> The drawback for "preloading" the responses to an interactive stream like this 
> is that neither ftp nor sftp include a way to determine whether or not the 
> commands worked. Had your sftp session not been able to connect to localhost, 
> or not been able to cd to /tmp, the "preloaded" command stream would have 
> failed, but /appeared/ to have worked.

In the part that you snipped, there were responses from 'sftp' that showed where the commands succeeded. You could capture and/or test for those if you wanted to. Plain FTP can be made verbose as well:

  -v    Verbose option forces ftp to show all responses from the remote
        server, as well as report on data transfer statistics.

It seems like all of that is definitive and testable - although I'd agree that it's not as easy as it should be.

> There /are/ (s)ftp clients that support scripting, and scripting languages 
> (like perl and php, for instance) that support (s)ftp, so this potential flaw 
> can be remedied.

That would be the standard remedy from my perspective. Net::SSH2 under Perl handles all of that for me.

> OTOH, the OP has yet to explain what he meant, so perhaps we are going down 
> the wrong path. I guess time will tell.  :-)

Hey, it's always fun to explore the alleys and the byways off the main drag. :)

-- 
* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *


Top    Back


Lew Pitcher [lew.pitcher at digitalfreehold.ca]


Mon, 9 Mar 2009 11:10:02 -0400

On March 9, 2009 10:51:28 Ben Okopnik wrote:

> On Mon, Mar 09, 2009 at 10:23:14AM -0400, Lew Pitcher wrote:
> > On March 8, 2009 18:28:31 Ben Okopnik wrote:
> > > On Sun, Mar 08, 2009 at 04:52:23PM -0400, Lew Pitcher wrote:
> > > > Note also that normally, both ftp and sftp are interactive; the
> > > > command invocation does not usually define all the file transfer
> > > > requirements.
> > >
> > > Actually, that part's pretty easy.
> > >
> > > ```
> > > ben@Tyr:~$ >FOOBAR
> > > ben@Tyr:~$ echo -e "cd /tmp\nput FOOBAR\n"|sftp ben@localhost
> >
> > [snip]
> >
> > True(ish)
> >
> > I've used something similar in a couple of my own projects.
> >
> > The drawback for "preloading" the responses to an interactive stream like
> > this is that neither ftp nor sftp include a way to determine whether or
> > not the commands worked. Had your sftp session not been able to connect
> > to localhost, or not been able to cd to /tmp, the "preloaded" command
> > stream would have failed, but /appeared/ to have worked.
>
> In the part that you snipped, there were responses from 'sftp' that
> showed where the commands succeeded. You could capture and/or test for
> those if you wanted to. Plain FTP can be made verbose as well:
>
> ``
>   -v    Verbose option forces ftp to show all responses from the remote
>         server, as well as report on data transfer statistics.
> ''

I hadn't thought about using post-analysis, but it sounds like it would work in most cases. I was thinking more of the inability to respond immediately to error conditions; if (in your example), the /tmp directory didn't exist, the "cd /tmp" would have failed, and your client session would potentially be left in the initial server-side directory. In this case, do you /really/ want the client to execute the "put FOOBAR"? FOOBAR might wind up in the wrong directory, necessitating some amount of clean-up that is cumbersome to perform after-the-fact.

> It seems like all of that is definitive and testable - although I'd
> agree that it's not as easy as it should be.

True. And if you are confident enough in the stability of your preloaded commands (and/or your post-analysis recovery), there's no reason /not/ to use this sort of setup. As I said, I've done exactly that in a number of different projects.

[snip]

-- 
Lew Pitcher
 
Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/   | GPG public key available by request
----------      Slackware - Because I know what I'm doing.          ------


Top    Back


Chris Bannister [mockingbird at earthlight.co.nz]


Fri, 20 Mar 2009 23:55:06 +1300

On Sun, Mar 08, 2009 at 02:13:09PM -0700, Rick Moen wrote:

> Quoting Don Saklad (dsaklad@gnu.org):
> 
> > How do you format ftp or sftp for transfering files?...
> 
> Why is a raven like a writing desk?
> 
> (You should, please, rephrase your question so that its semantic payload
> is more easily understood.)
cough

I presume he means "configure". And sorry I don't know how -- there are probably many ways. http://catb.org/~esr/faqs/smart-questions.html

-- 
Chris.
======
I contend that we are both atheists. I just believe in one fewer god
than you do. When you understand why you dismiss all the other
possible gods, you will understand why I dismiss yours.
                                           -- Stephen F Roberts


Top    Back


Rick Moen [rick at linuxmafia.com]


Fri, 20 Mar 2009 09:42:33 -0700

Quoting Chris Bannister (mockingbird@earthlight.co.nz):

> On Sun, Mar 08, 2009 at 02:13:09PM -0700, Rick Moen wrote:
> > Quoting Don Saklad (dsaklad@gnu.org):
> > 
> > > How do you format ftp or sftp for transfering files?...
> > 
> > Why is a raven like a writing desk?
> > 
> > (You should, please, rephrase your question so that its semantic payload
> > is more easily understood.)
>  cough 
> 
> I presume he means "configure".
> And sorry I don't know how -- there are probably many ways.

It's certainly possible that Don meant "configure" ("How do you configure ftp or sftp for transferring files?"), but that would leave entirely unclear what exactly the problem Don's trying to solve is.

Ideally, someone posing such a problem online would say "I tried [foo], and then [bar], and what then resulted was [baz]", i.e., an explicit (but concise, please!) chronological account that we can reproduce to observe the symptom for ourselves.

As it turns out, for all ftp and sftp clients of my acquaintance, no configuration is either necessary or useful, except sometimes putting ftp clients in "passive" mode to better deal with the more mulish firewalls. However, again, it might be possible to give a more meaningful answer if Don would say which ftp and sftp clients he tried, and what specific conundrum he encountered.

If the problem is solely that he hasn't yet tried any, maybe it's smarter to just do that, rather than hit up help resources about speculative, vaguely defined problems he thinks may or may not exist.

> http://catb.org/~esr/faqs/smart-questions.html

I don't know if I'd put much stock in that essay: One of the co-authors is a Scandinavian, and my Tante Bjorg always warned me about them!

By the way, the canonical suggested answer to the Mad Hatter's famous unanswered riddle ("Why is a raven like a writing desk?") was eventually provided by Martin Gardner in _The Annotated Alice_: "Because they were both written on by Poe."

-- 
Cheers,              Crypto lets someone say "Hi! I absolutely definitely have 
Rick Moen            a name somewhat like the name of a large familiar 
rick@linuxmafia.com  organization, and I'd like to steal your data!" and lots 
McQ!  (4x80)         of users will say "OK, fine, whatever."    -- John Levine 


Top    Back