[Gambas-user] Interaction With Command Shell

Tobias Boege taboege at ...626...
Mon Mar 16 22:44:48 CET 2015


On Mon, 16 Mar 2015, Beno?t Minisini wrote:
> Le 16/03/2015 16:31, Tobias Boege a ?crit :
> > On Mon, 16 Mar 2015, Nigel Verity wrote:
> >> Hi
> >>
> >> I would welcome some advice about interacting with the Linux command shell from within a Gambas application.
> >>
> >> The requirement is to create a connection with a remote server using SSHFS. The general syntax for this command is:
> >>
> >> sshfs username at ...3453...:/foldername /local-mount-folder
> >>
> >> There is no option in the SSHFS command to include the user's password on the remote server. When running from a command prompt, once the sshfs command is accepted you are then prompted to enter the password.
> >>
> >> Is there any way, after executing the SSHFS command (using SHELL, presumably) to monitor for the password prompt and then send the password to the command shell?
> >>
> >> My aim is to create a dialog in which the user provides the server name, username and password and have Gambas do the rest to create the SSHFS connection.
> >>
> >
> > I have once tried that, specifically with sshfs, too, and failed miserably.
> > Your zeroth approximation should be to factor out Gambas and write a shell
> > script which can pass the password to sshfs. If you've got that, you almost
> > have the solution in Gambas.
> >
> > There is a program "expect" which was designed for specifically the purpose
> > of waiting on a program's output for a specific pattern and then sending a
> > given string to its input (i.e. to automate interactive programs). But it
> > seems sshfs is putting extra effort into preventing this automation.
> >
> > I ended up creating a private/public key pair and have the server work with
> > that so that I can login using these keys[0]. Maybe this is an option for
> > you, too?
> >
> > If you can trick sshfs into being automated via expect or some other means,
> > please let me know :-)
> >
> > Regards,
> > Tobi
> >
> > [0] https://help.ubuntu.com/community/SSH/OpenSSH/Keys
> >
> 
> I'm automating scp and ssh daily with Gambas, by detecting when the 
> password prompt appears (and the ssh key confirmation question too).
> 
> It cannot be 100% reliable, because any other program can print 
> "password:" on its standard output, and apparently there is no way to 
> know that a program is waiting for input.
> 
> But in practise it works.
> 
> If there is no clean way to do that, maybe I should make a component 
> with that, even it's some quick & dirty hack?
> 

I would definitely like to see it. I have a project here which can pipe a
password into sudo and I remember seeing forum threads where others could
automate sshfs mounts but all those approaches didn't work with my sshfs.
(That's why I suspected that they put extra effort into preventing auto-
 mation, be it for their amusement or to discipline users.)

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list