aplumb at westpac.com.au
2003-Feb-19 22:15 UTC
newbie wants to compile SCP into his own application
Hi all, I have seen in the OpenSSH source that the scp executable is built by compiling scp.c and linking with libopenbsd-compat.a and libssh.a. (Correct me here if I'm wrong) My question is, can I make this a module in my own application by using the scp.c source and ilnking the libraries mentioned above ? The reason is, I want to perform an SCP from my application, but I don't want to execute the external command line utility "scp". I want to be able to get a return value to indicate success or failure and handle this in my app. Thanks, Andrew Plumb.
aplumb at westpac.com.au wrote:> My question is, can I make this a module in my own application by using the > scp.c source and ilnking the libraries mentioned above ? The reason is, I > want to perform an SCP from my application, but I don't want to execute the > external command line utility "scp". I want to be able to get a return > value to indicate success or failure and handle this in my app.Probably, but it's likely to be much easier (and less maintenance too) to just fork/exec scp then wait() for completion and check the return code. Is determining success/failure the only reason you want to embed the code? I've got some example code that might serve as a starting point if you want it. -Daz. $ scp localhost:/bin/ls /tmp/ls $ echo $? 0 $ scp localhost:/no/such /tmp/ls scp: /no/such: No such file or directory $ echo $? 1 -- Darren Tucker (dtucker at zip.com.au) GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4 37C9 C982 80C7 8FF4 FA69 Good judgement comes with experience. Unfortunately, the experience usually comes from bad judgement.
First off I suggest you look at sftp rather than scp. There are less integration issues and I believe you'll be more happy with the results. Second, you just can just add scp.c and libopenbsd-compat.a into your code and think you don't have nay more external dependances. Just keep in mind scp forks to call ssh (same is true with sftp). But in general, sftp code is much friendlier for integrating since it was designed for that reason. scp (for how wonderful it is) is really a hack on a hack on a hack.=) - Ben On Thu, 20 Feb 2003 aplumb at westpac.com.au wrote:> Hi all, > > I have seen in the OpenSSH source that the scp executable is built by > compiling scp.c and linking with libopenbsd-compat.a and libssh.a. (Correct > me here if I'm wrong) > > My question is, can I make this a module in my own application by using the > scp.c source and ilnking the libraries mentioned above ? The reason is, I > want to perform an SCP from my application, but I don't want to execute the > external command line utility "scp". I want to be able to get a return > value to indicate success or failure and handle this in my app. > > Thanks, > > Andrew Plumb. > > > > > _______________________________________________ > openssh-unix-dev mailing list > openssh-unix-dev at mindrot.org > http://www.mindrot.org/mailman/listinfo/openssh-unix-dev >
aplumb at westpac.com.au
2003-Feb-24 01:19 UTC
newbie wants to compile SCP into his own application
OK, I'll look into using sftp instead.... do you (or anyone else) have sample code for integrating sftp ? Andrew. Ben Lindstrom <mouring at etoh.evil To: aplumb at westpac.com.au admin.org> cc: openssh-unix-dev at mindrot.org Subject: Re: newbie wants to compile SCP into his own application 20/02/2003 10:07 First off I suggest you look at sftp rather than scp. There are less integration issues and I believe you'll be more happy with the results. Second, you just can just add scp.c and libopenbsd-compat.a into your code and think you don't have nay more external dependances. Just keep in mind scp forks to call ssh (same is true with sftp). But in general, sftp code is much friendlier for integrating since it was designed for that reason. scp (for how wonderful it is) is really a hack on a hack on a hack.=) - Ben On Thu, 20 Feb 2003 aplumb at westpac.com.au wrote:> Hi all, > > I have seen in the OpenSSH source that the scp executable is built by > compiling scp.c and linking with libopenbsd-compat.a and libssh.a.(Correct> me here if I'm wrong) > > My question is, can I make this a module in my own application by usingthe> scp.c source and ilnking the libraries mentioned above ? The reason is, I > want to perform an SCP from my application, but I don't want to executethe> external command line utility "scp". I want to be able to get a return > value to indicate success or failure and handle this in my app. > > Thanks, > > Andrew Plumb. >
aplumb at westpac.com.au
2003-Feb-24 20:59 UTC
newbie wants to compile SCP into his own application
Forgive my ignorance, but what is the tree ?? Andrew. Ben Lindstrom <mouring at etoh.evil To: aplumb at westpac.com.au admin.org> cc: openssh-unix-dev at mindrot.org Subject: Re: newbie wants to compile SCP into his own application 24/02/2003 12:24 No clue.. but I think the code in the tree is pretty clear on the subject. - Ben On Mon, 24 Feb 2003 aplumb at westpac.com.au wrote:> > OK, I'll look into using sftp instead.... do you (or anyone else) have > sample code for integrating sftp ? > > > Andrew. >