By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,742 Members | 773 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,742 IT Pros & Developers. It's quick & easy.

Automating user interaction

P: 1
Hi All,

Can someone guide me on how we can modify the below script so that no user interaction is required to feed the password when the script is run, current scenario is like if I try to login to a different user from a user other than root it needs user interaction for that, but it should not ask for the user interaction and it should get the password from the script itself.

This is the script to modify;and it prompts me for the password as below;

$ ./ora1.pl
Data base is down
Password:

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2.  
  3. use Log;
  4. use testDMC;
  5.  
  6. my $logFH;
  7. my $testDMCRef;
  8. my %parameterHash;
  9. my $oracle_passwd;
  10.  
  11. $logFH = Log->new(1,"log/masterDMCTest.log");
  12. $testDMCRef = testDMC->new($logFH);
  13.  
  14. my $var = " ps -ef | grep ora_smon_dmc| grep -v \"grep\" ";
  15. my $execcommand = qx/$var/;
  16. if ($execcommand) {
  17.     print "Database is up\n";
  18. } else {
  19.     print "Data base is down\n";
  20.     #system("su - oracle");
  21.  
  22.     %parameterHash = $testDMCRef->ReadTestDmcConfig();
  23.     $oracle_passwd = $parameterHash{ORACLEUSRPWD};
  24.     system("su - oracle");
  25.     #print "\n$oracle_passwd\n";
  26.     #print "\nhello\n";
  27.     #system("sqlplus /nolog");
  28. }
  29.  
Aug 22 '07 #1
Share this Question
Share on Google+
1 Reply


miller
Expert 100+
P: 1,089
To automate user interation you will need to use the Expect module instead of the system command.

cpan Expect.

- Miller
Aug 22 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.