Sponsored Content
Full Discussion: Perl script stopped working
Top Forums Shell Programming and Scripting Perl script stopped working Post 302904236 by belalr on Tuesday 3rd of June 2014 04:37:12 AM
Old 06-03-2014
Perl script stopped working

Hi,

I have the following segment of a script which is supposed to prompt a user for password and then capture the password entered by the user.

The function is called in by another script and used to work without issue, the problem is that recently the script is not waiting for the user to input the password it and immediately the calling script is giving an error that null password is provided.

Can someone please help?


Code:
sub prompt_for_password
{
  my $account_name = $_[0];
  my $account_description = $_[1];
  my $display_prompt = $_[2];

  if ($display_prompt)
  {
    print STDERR "\n";
    print STDERR "Please enter password for $account_description '$account_name': ";
  }

  $LINUX = -d "/initrd";
  $SOLARIS = -d "/kernel";

  if ($LINUX)
  {
    system "/bin/stty cbreak -echo </dev/tty >/dev/tty 2>&1";
  }

  if ($SOLARIS)
  {
    system "/bin/stty icanon -echo </dev/tty >/dev/tty 2>&1";
  }

  $password = <STDIN>;

  if ($LINUX)
  {
    system "/bin/stty cbreak echo </dev/tty >/dev/tty 2>&1";
  }

  if ($SOLARIS)
  {
    system "/bin/stty icanon echo </dev/tty >/dev/tty 2>&1";
  }

  if ($display_prompt)
  {
    print STDERR "\n";
  }

  chomp($password);

  return $password;
}

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

#!/bin/bash has stopped working

Hi I'm writing a script and I've put #!/bin/bash as the first line so that I can just type my scripts name 'whodate' at PS1 instead of ./whodate. This has suddenly stopped working for me. It used to be the case that I could start a script with #!/bin/bash and it would work, but for this script... (2 Replies)
Discussion started by: zorrokan
2 Replies

2. Linux

Cronjobs stopped working

Hi All, I am user of a Linux machine and I have approximatly 15 cronjobs scheduled in my crontab. Yesterday my administrator made LDAP active on my userid and all the things are doing fine after that. But all cronjobs for my user id stored in my crontab have stopped working after that. Could... (1 Reply)
Discussion started by: bisla.yogender
1 Replies

3. Shell Programming and Scripting

cronjobs stopped working

Hello people, I had these cronjobs scheduled in some Unix boxes which were running fine until yesterday.But then the password was changed for that user id and then the jobs stopped working. As far as i know cron jobs run from super user. I am completely lost over here now. Thanks. (2 Replies)
Discussion started by: King Nothing
2 Replies

4. UNIX for Advanced & Expert Users

suPHP stopped working after dist-upgrade

Hi all, My server was Debian Etch (4) and had a working suPHP module (version 0.6.2-1). After I dist-upgraded it to Lenny (Debian 5), suPHP (version 0.6.2-3) stopped working. I read in the mailing list that I should change the settings of /etc/suphp/suphp.conf to this form: ;Handler... (1 Reply)
Discussion started by: mjdousti
1 Replies

5. IP Networking

Wireless stopped working- Fedora 12

I installed F12 around the time it was released and it picked up my wireless card and worked like a charm.....Suddenly last week everything stopped working and I receive what appears to be a driver error when wlan0 tries to load. Error for wireless request "Set Mode" (8B06) : SET failed on... (1 Reply)
Discussion started by: woodson2
1 Replies

6. Ubuntu

Ubuntu 10.10 LAN connection stopped working...

Well this is weird. I restarted my dual boot Win7/Ubuntu 10.10 from ubuntu to windows. Everything was working fine and windows is always connecting properly to my lan. After restarting back into Ubuntu, all of a sudden I can't connect to my network. It looks as if its trying to connect through... (15 Replies)
Discussion started by: zixzix01
15 Replies

7. UNIX for Dummies Questions & Answers

Ssh stopped working AIX

I Was able to ssh into the AIX box. now i cannot When I run the command to start it it comes back that is was started, but still does not work. Here is a shot i what i see # server:/> lslpp -l | grep ssh openssh.base.client 4.3.0.5201 COMMITTED Open Secure Shell Commands ... (2 Replies)
Discussion started by: fierfek
2 Replies

8. AIX

Printer stopped working

I have a serial printer connected to a 16 port ran. All of a sudden my printer stopped working and not sure how to get it back. Can anyone help pint me in the write direction? lsdev -Cc printer gives me the following. lp0 Defined 0A-08-11-00 Other serial printer lp1 Defined 0A-08-11-03... (3 Replies)
Discussion started by: Gmanx
3 Replies

9. Solaris

Mailx stopped working

after a new patch set on the 14th. I noticed that mailx stopped working, as far a I can tell that is the only thing that changed. solaris 10 OS it seems everything is the same, sendmail seems to be running root@server # ps -ef | grep -i sendmail smmsp 687 1 0 10:42:25 ? ... (0 Replies)
Discussion started by: goya
0 Replies
OSINFO-INSTALL-SCRIPT.C(1)				      Virtualization Support					OSINFO-INSTALL-SCRIPT.C(1)

NAME
osinfo-install-script - generate a script for automated installation SYNOPSIS
osinfo-install-script [OPTIONS...] OS-ID DESCRIPTION
Generate a script suitable for performing an automated installation of "OS-ID". "OS-ID" should be a URI identifying the operating system, or its short ID. By default a script will be generated for a "JEOS" style install. OPTIONS
--profile=NAME Choose the installation script profile. Defaults to "jeos", but can also be "desktop", or a site specific profile name --config=key=value Set the configuration parameter "key" to "value". CONFIGURATION KEYS
The following configuration keys are available "hardware-arch" The hardware architecture "l10n-timezone" The local timezone "l10n-keyboard" The local keyboard layout "l10n-language" The local language "admin-password" The administrator password "user-password" The user password "user-login" The user login name "user-realname" The user real name "user-autologin" Whether to automatically login the user "user-admin" Whether to give the user administrative privileges "reg-product-key" The software registration key "reg-login" The software registration user login "reg-password" The software registration user password EXAMPLE USAGE
The following usage generates a Fedora 16 kickstart script # osinfo-install-script --profile jeos --config l10n-timezone=GMT --config l10n-keyboard=uk --config l10n-language=en_GB --config admin-password=123456 --config user-login=berrange --config user-password=123456 --config user-realname="Daniel P Berrange" fedora16 EXIT STATUS
The exit status will be 0 if an install script is generated, or 1 on error AUTHORS
Daniel P. Berrange <berrange@redhat.com> COPYRIGHT
Copyright (C) 2012 Red Hat, Inc. LICENSE
"osinfo-install-script" is distributed under the termsof the GNU LGPL v2 license. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE libosinfo-0.2.7 2013-04-10 OSINFO-INSTALL-SCRIPT.C(1)
All times are GMT -4. The time now is 04:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy