dayhkr has asked for the wisdom of the Perl Monks concerning the following question:

I am building a front end to a program using perl, Glade::XML and expect. From within the script I am spawning a session to start the command line program then I look for the password prompt and send the password to the program. The problem is I never see the prompt and I found that apparently the program starts another gnome-terminal session so expect can not see the prompts. Can anyone help me work around this issue I have searched everywhere that I can think of and I can not find a solution.

Replies are listed 'Best First'.
Re: Perl Expect
by ysth (Canon) on Jul 05, 2009 at 17:10 UTC
      Yes it is the Linux Ironkey unlocker when I run strace on it I see the execve("program") that is causing the new console.
Re: Perl Expect
by ww (Archbishop) on Jul 05, 2009 at 17:38 UTC

    Then maybe you had best show us your script or (at least) the relevant part spawning a session.

      Below is the sub that controls the external program everything else in the program is for controlling the Glade interface. I can provide the rest of the code if needed but I didn't want to muddy up the source of my issues.
      sub decrypt_key{ my $Ironkey = '/media/IronKey/linux/ironkey'; my $Ironkey_pwd = 'Enter your IronKey password: '; my $Ironkey_sucess = 'Unlock successful. '; my $Ironkey_badpw = 'password not accepted '; my $data = ($entry->get_text()); chomp($data); $entry->set_text(''); #sleep(2); $exp = Expect->spawn("$Ironkey") or die "Cannot Spawn"; #$exp->debug(3); #$exp->raw_pty(1); $exp->exp_internal(1); #$exp->log_stdout(0); $exp->expect(60, "$Ironkey_pwd"); $exp->send("$data\r"); #$data comes from the password box of the +GUI frontend ## I tried this way as well #$exp->expect(60, # [ qr/password:/ => sub{ $exp = shift; # $exp->send("$data\r\n"); # exp_continue; # }], # ); $exp->soft_close(); #system("nautilus"); Future use }