Solved

System Function

Posted on 1998-09-21
2
137 Views
Last Modified: 2010-03-05
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
0
Comment
Question by:context
2 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1204934
#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;
0
 
LVL 4

Accepted Solution

by:
binkzz earned 50 total points
ID: 1204935
Try this,

print "\nEnter userid :";
$userid = <STDIN>;

print "\nEnter password :";
$password = <STDIN>;

open infofile, ">>cmds.file";
print infofile "$userid\n";
print infofile "$password\n";
close infofile;

This should help you out quite nicely.
If it doesn't though, please also note the operating system
you have.

Binkzz
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now