Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Process Inputs

Status
Not open for further replies.

DANZIG

Technical User
Joined
Mar 8, 2001
Messages
142
Location
US
Hello I have an external commandline proccess that I need to execute. The process takes 2 inputs though the first is an ARGV the second is the RUNNING process asking for another piece of information. As I'm calling the process using backticks`` I can't feed it the second piece on information that follows the processing of the first. I am running this on a NT box. If I'm going about it the wrong way please let me know (An exapmle would be nice) or if there's just a step I'm missing.

Thanks in advance. ;)
 
why not just run the script with two inputs from the command line like:

$valueA = @ARGV[0];
$valueB = @ARGV[1];

or do your inputs have spaces in them?


Steve Kiehl
webmaster@nanovox.com
 
Well the problem is that it's being fed 2 ARGVS and can't be passed the 3'rd on the command.

Prog ARGV1 ARGV2
H:\>runas /user:someuser scandisk.exe


After execution you are prompted for this.


Enter password for someuser:


Any ideas on how to wait for the proccess to request an input and send the 3'rd ARGV (somepassword) ?
 
You could try running the command on the end of a pipe, like this:
[tt]
open(CMD, "|runas /user:someuser scandisk.exe")
[tab]|| die "$!"
print CMD "thepassword\n";
close(CMD);
[/tt]


It's a way of running a command and then feeding stuff (the password, in this case) into it's STDIN.

This may or may not work, depending upon whether or not the runas program uses STDIN to accept its input.
Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
I don't know if you could mask the input of the keyboard, but you can use STDIN to get input from the console while the script is running. For example:

#!/usr/bin/perl
print "Enter your password:";
$password = <STDIN>;
print &quot;Your password was:$password&quot;;

.......

This script will look something like this when run:

Enter your password:mypassword
Your password was:mypassword
Steve Kiehl
webmaster@nanovox.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top