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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
#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;