RE: [JSch-users] Newbie - how to use for mulitple command
Status: Alpha
Brought to you by:
ymnk
From: Randy B. <Randy.Bowie@NetIQ.com> - 2004-08-20 14:22:36
|
You can also look at the TelnetWrapper object in JTA, you can download it at javassh.org. It's pretty easy to hack it to use jsch or just use it as a reference code. In this case you would do the same thing you do with expect just in java instead of TCL. Hope this helps! Randy -----Original Message----- From: jsc...@li... [mailto:jsc...@li...]On Behalf Of Rob Meyer Sent: Friday, August 20, 2004 8:53 AM To: Atsuhiko Yamanaka Cc: ben...@bi...; jsc...@li... Subject: Re: [JSch-users] Newbie - how to use for mulitple command Since you are doing a sudo, you may have more trouble than just separating commands with ";". If you have the sudo rights, then make sudo run your commands individually: command="sudo chown ${perms} foo.txt; sudo chown ${perms} bar.txt" That will work okay. If you only have sudo to su with no arguments, then you're in a tough spot. You won't be able to do something like: command="sudo su ${username}; chmod ${perms} foo.txt" Because the first command will execute a new interactive shell, which will wait for input indefinitely. Once it closes/ends/dies, then you will return to the original shell which is running your ssh command, and it will perform the rest of the command line, which is the chmod. But it will no longer have the sudo'ed identity. If you're allowed to run sudo su with any arguments, then you can put it on each command: command="sudo -u su ${username} chmod ${perms} foo.txt; \ sudo -u su ${username} chmod ${perms} bar.txt" These are all sudo/unix specific things really, rather than jsch stuff, but it's probably somewhat common usage so I figured I'd reply to the whole list. If a password is required for sudo'ing in your situation, you have trouble doing that as well. The one heavy-duty tool for getting around all of this is expect (http://expect.nist.gov. It lets you completely automated any interactive program, so you could write a small expect script that would do the sudo, execute your commands, and exit the shell. I've had to do that before. On Fri, Aug 20, 2004 at 01:46:09PM +0900, Atsuhiko Yamanaka wrote: > Hi, > > +-From: "Benz Lim" <ben...@bi...> -- > |_Date: Tue, 17 Aug 2004 10:25:40 +0800 ____ > | > |How can we use ant task <sshexec> to carry out multiple command? > |for example if I need to do a sudo su after which need to enter > |the password and perform a change ownership command (chown) on > |some files > > The command will be evaluated by your remote login shell interpreter. > So, you can pass commands by concatenating them with ';' as you will > on the command line of shell. For example, > > command="chown ${chown.user}:${chown.grp} foo.txt ; \ > chown ${chown.user}:${chown.grp} bar.txt" > > Thanks, > -- > ymnk > > > ------------------------------------------------------- > SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media > 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 > Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. > http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 > _______________________________________________ > JSch-users mailing list > JSc...@li... > https://lists.sourceforge.net/lists/listinfo/jsch-users -- Rob Meyer - http://www.evilrob.org/ - http://www.bigdis.com/ ------------------------------------------------------------------------- "Ignorance more frequently begets confidence than does knowledge." -- Charles Darwin ------------------------------------------------------- SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 _______________________________________________ JSch-users mailing list JSc...@li... https://lists.sourceforge.net/lists/listinfo/jsch-users |