Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: here document help

by superfrink (Curate)
on Apr 03, 2008 at 18:34 UTC ( #678236=note: print w/ replies, xml ) Need Help??


in reply to here document help

First of all (just so you know) the code is using a Bourne Shell heredoc. Not a perl heredoc.

I don't see any problem with the code. I ran the following (on Fedora 6):

#! /usr/bin/perl -w use strict; use Data::Dumper; my @result = `sh << EOF; pwd; sleep 10; date; EOF`; print Dumper(\@result);
The output looked fine:
$ ./678154.pl $VAR1 = [ '/home/chad ', 'Thu Apr 3 12:27:32 MDT 2008 ' ];
The ps output looks fine.
6204 pts/1 S+ 0:00 sh -c sh << EOF;?pwd;?sleep 10;?date;?EOF
Have you tried running the command from a shell yourself? I suspect the ssmcons program is hanging. Maybe 192.168.2.114 is not responding or closing the connection.


Comment on Re: here document help
Select or Download Code
Re^2: here document help
by srinivas_rocks (Sexton) on Apr 04, 2008 at 13:11 UTC
    Thanks for the reply

    I tried to execute the command in the command prompt with an <Enter> after each statement and it is giving me the correct output with out hanging.

    since I am new to this perl programming..can you tell me whether a script working from command prompt will hang when executed from perl script?

    waiting for your valuable suggestions.

    Srinivas.

      Launching a shell interactively and manually entering the script line by line is different from launching a shell with a here-document.

      I recommend that you either launch the shell with the commands to execute separated by semicolons or that you write out a shell script and launch that shell script from Perl. Both ways are far easier to debug.

      Also, I'm not really sure whether your command line is correct. You should launch the shell with sh -c commands... and not sh comands... I think. But then, I avoid such trickery.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://678236]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2014-08-23 02:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (171 votes), past polls