Link to home
Start Free TrialLog in
Avatar of context
context

asked on

System Function

Hi,

Want to use a PERL script to get some variables in Kshell from the user and write them to a file.
The script works in Kshell but if I use PERL & the system function, the variables aren't recognised.

system('echo Enter userid');
system('read userid');
system('echo Enter password');
system('read passw');
system('echo $userid >> cmds.file');
system('echo $passw >> cmds.file');

Any ideas?

Thanks,

Andreas
Avatar of ozo
ozo
Flag of United States of America image

#each system call invokes a new shell
#you can do
system('echo Enter userid
read userid
echo Enter password
read passw
echo $userid >> cmds.file
echo $passw >> cmds.file');
#or
print "Enter userid\n";
$userid = <>;
print "Enter password\n";
$passw = <>;
open(FILE,'>>cmds.file') or die "can't open cmds.file because $!";
print FILE $userid,$passw;
close FILE;
ASKER CERTIFIED SOLUTION
Avatar of binkzz
binkzz

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial