PERL - press Enter function hanging


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting PERL - press Enter function hanging
# 1  
Old 12-08-2011
PERL - press Enter function hanging

Hi,

I have a sub function called pressEnter within my perl menu script which basically means that the script will await an interaction from the user before moving on.

Unfortunately when the script goes into pressEnter it just hangs (even if you press enter!!).

Any ideas on what could be causing this?

Code:
sub checkJob
{
system('clear');
print "The current Job Status is:\n\n";
      `./scriptlist.ksh 2`;
      open OUTPUT, "./output";
      undef $/;
      $_ = <OUTPUT>;
      ($var) = m/^(INTE.*PM)$/sm;
      print "$var\n\n";
      close OUTPUT;
      pressEnter();
    }
sub pressEnter
{
print "Press Return to continue\n\n";
      $dummy = <>;
      mainMenu();
}

I've included another sub function so you can see how it is called.
# 2  
Old 12-08-2011
"($var) = m/^(INTE.*PM)$/sm;" --> What're you trying to do here?

Did you mean:
Code:
$var = <OUTPUT>;
$var =~ m/^(INTE.*PM)$/sm;

Not sure if this is what you wanted. Give this a try:
Code:
sub checkJob
{
    system('clear');
    print "The current Job Status is:\n\n";
    `./scriptlist.ksh 2`;
    open OUTPUT, "./output";
    undef $/;
    $var = <OUTPUT>;
    if ($var =~ m/^(INTE.*PM)$/sm) {
        print "$var\n\n";
    }
    close OUTPUT;
    pressEnter();
}

sub pressEnter
{
    while (1) {
        print "Enter: ";
        $x = <STDIN>;

        if ($x eq "\n") {
            mainMenu();
            last;
        }
    }
}

# 3  
Old 12-08-2011
I think the culprit might be the mainMenu() function. What's in it?
# 4  
Old 12-09-2011
Code:
sub mainMenu
{
system('clear');
print <<MENU_END;
******************SYSCON MENU******************
    [1].................Check Backlog
    [2].................Check Job Status
    [Q].................Quit
MENU_END
print "\n";
print "What do you want to do?: ";
  my$decision;
  chomp($decision = <>);
if ($decision !~ /^q/i) {
    $decision == 1 && do { checkIso(); };
    $decision == 2 && do { checkJob(); };
    }
}

---------- Post updated at 12:05 PM ---------- Previous update was at 11:18 AM ----------

Also, on closer inspection it doesn't just hang. If I press enter it will linefeed down the terminal.
# 5  
Old 12-09-2011
Look here:
Code:
print <<MENU_END;

and here:
Code:
MENU_END

You are missing a semicolon, so your here-document never ends...

That's why you never see "What do you want to do?: "
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script that automatically issue "yes" and press enter

Team, Got a thousand servers. I created a script to say hello on every server. But is there a script or whatever that will issue a yes on every key checking. for i in `cat myserverlist` do echo $i ssh-copy-id $i done The authenticity of host 'server1 (162.162.0.10)' can't be... (7 Replies)
Discussion started by: invinzin21
7 Replies

2. Shell Programming and Scripting

enter key or carriage return as input in perl

hi experts Question in perl i'm creating a script to take from user a different inputs one of them is the carriage return .. so that i want to make an if condition if the user hit enter key the user will go to previous step it something like that chomp ($input = <STDIN>); if ($input =~... (3 Replies)
Discussion started by: doubando
3 Replies

3. Shell Programming and Scripting

"Write" - how to quit by press enter

I need to make Bash script. It has one parameter - user ID. If this user is online you can write him a message with "write" program, but only one line. After pressing ENTER "write" program should quit. Normally when you run "write" you can write next line after pressing ENTER and you can quit... (0 Replies)
Discussion started by: Eriknem
0 Replies

4. Shell Programming and Scripting

Perl - Enter text in a file in a place.

Hi, I have a simple question: I need to enter some text in a text file at a certain place via perl. I would first need to find that specific text in the file and then I would like to insert a line after that particular line. Say I have this text file: I am a great Perl Programmer I... (1 Reply)
Discussion started by: som.nitk
1 Replies

5. Shell Programming and Scripting

Perl Script Hanging

Hey, Does anyone know why my Perl script is hanging when i execute it. print "looking around ...\n"; my ($out, $err, $exit) = $scon->cmd('ls'); print "done"; i get the following error: channel 1: open confirm rwindow 131043 rmax 32768 I'm using use Net::SSH::W32Perl Module.... (4 Replies)
Discussion started by: Phi01
4 Replies

6. Programming

capturing enter and exit of every function

If I have a "Hello World" function (just prints that) and a similar "Goodbye World" function... is there a way (maybe a compiler option?) that I can get them to be executed directly as the absolute first and last things run in every function call. So for example, the following code: int foo()... (5 Replies)
Discussion started by: jjinno
5 Replies

7. Shell Programming and Scripting

Limiting the hanging of a function inside a loop

#! /bin/ksh ..(some lines are here..) for t in (LIST) do a=function($t) #here I want to wait till the function hangs for 5 secs else want to continue the loop for other values of t. done if ;then ............. fi ...... ...................... Suppose in this script;... (7 Replies)
Discussion started by: Niroj
7 Replies

8. UNIX for Advanced & Expert Users

can hanging perl process wipe out a directory?

Hi, This weekend i left a perl script running , I was running it in a remote machine. The machine seems to have been rebooted during the weekend. When i got back on monday the entire directory containing the script was wiped out. The process had been aborted. Nobody has access to the directory... (2 Replies)
Discussion started by: aboxilica
2 Replies
Login or Register to Ask a Question