commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael K. Craghead" <>
Subject Re: [commons-exec] How to exec scp from cygwin?
Date Fri, 03 Apr 2009 21:43:27 GMT
It turned out to be relatively simple. All I had to do was create a command line with a string
of the absolute path of cygwin (relative path probably works as well if cygwin is in your
PATH or System Path):

Executor exec = new DefaultExecutor();
CommandLine cl = new CommandLine("c:\\cygwin\\cygwin.bat");

The part that I was confused about was how to get the Executor to take the scp as part of
the cygwin and not a windows command since the openssh package works as part of cygwin and
not windows (if anyone knows how to use a cygwin ssh package directly from Windows please
let me know). All I needed was a pipe ('|'). I didn't think it would be that simple, as it's
been years since I've done any real work on *NIX without a GUI interface of some sort.

cl.addArgument(StringUtils.quoteArgument("/cygdrive/c/Documents and Settings/michael/some

Of course I had to use the quoteArgument() method for the absolute path of the file to be
transferred since it has spaces and *NIX doesn't like spaces. That was it. I think cygwin
would stay 'active' as long as you kept adding pipes and *NIX commands/scripts to the command
line. I haven't played with it. It's just a guess.

For me, the hardest part was just getting openssh setup properly since I hadn't used it before.

Thanks for your interest.
 Michael K. Craghead 

From: Siegfried Goeschl <>
To: Commons Users List <>
Sent: Friday, April 3, 2009 4:38:52 PM
Subject: Re: [commons-exec] How to exec scp from cygwin?

Hi Michael,

no idea since I never used cygwin but it would be highly appreciated if
you share your insights ....

Thanks in advance

Siegfried Goeschl

Michael K. Craghead wrote:
> Looking at the tutorial for exec it doesn't look to difficult to use, but I'm not sure
how to go about setting up an exec for an scp command that runs inside of cygwin. Can someone
point me in the right direction? Thanks.
>  Michael K. Craghead 

To unsubscribe, e-mail:
For additional commands, e-mail:
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message