Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Calling an executable and entering login credentials

by Thomas Kennll (Acolyte)
on Sep 02, 2012 at 15:54 UTC ( [id://991292]=perlquestion: print w/replies, xml ) Need Help??

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

Is it possible to open an executable file and pass user credentials through the perl script. If yes Please do share the CPAN module names and the way to access the executable file. For eg. I want to open the IBM LOTUS Sametime through my perl code and pass the user credentials like username,password and hostname through my perl script. Any suggestions,ideas on the above will be much helpful for me.....

Replies are listed 'Best First'.
Re: Calling an executable and entering login credentials
by zentara (Archbishop) on Sep 02, 2012 at 16:58 UTC
    I don't know exactly how Sametime expects to get it's login, can you be more specific what the program does? Does it output a prompt, like Login:? Usually to interact with a program, the Expect module is usually recommended, google for perl Expect for sample code.

    In a very simple situation, you may be able to get by with IPC::Open3, which opens the program, and gives you pipes to write to, and read from, the executable.

    A simple example:

    #!/usr/bin/perl use warnings; use strict; use IPC::Open3; $|=1; # you would run Sametime here, instead of bash my $pid=open3(\*IN,\*OUT, \*ERR , '/bin/bash'); # set \*ERR to 0 to send STDERR to STDOUT # # in your case, print the login name here my $cmd = 'date'; #send cmd to bash print IN "$cmd\n"; my $result = <OUT>; print $result;

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
      Thanks for the reply! Actually the application is a .bat file and when I run this manually a login/password prompt pops up.. I need to put in the username and password and then submit it.. Something like a form program.. I want my perl script to interact to this .bat file and put in the credential and submit..

        To interact with GUI programs on Windows, you should check out Win32::GUITest and its excellent examples.

        Batch files don't ask for passwords. Programs invoked by the batch files do that. Look at the batch file, find out which program asks for a password, read its documentation and find a way to pass the password on the command line. Or look at tools like AutoIt that are written to interact with GUIs.

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://991292]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-03-19 07:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found