Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
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.

Replies are listed 'Best First'.
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?
[Corion]: No. It's just that I'm comparing the same output file twice, instead of comparing the output files of the two runs %-)
[Corion]: Lo and behold, running a program with the correct input files yields the correct (and expected) output. Yay me.
[1nickt]: Got a MacBook and am expected to develop directly on it, ironic given the recent thread about that.
[marto]: Corion, some not too serious issues with the kids, hopefully, other than that just dealing with commuting by car again in the winter, not much fun so far, and there's no real 'bad' weather yet :)
[marto]: 1nickt, glad to hear it, I'm sure you'll bring improvements to their stack in due course ;)
[1nickt]: Just trying to adjust to a new culture. Better doc than I am used to , but quite a bit more Agiley meta-bullshit; at least half a dozen meetings a week, strict "sprint" schedule etc. I'll adjust. And I hope to just switch off after the "scrum" each day at
[1nickt]: ... the end of the afternoon. marto How are you, snowed in? Mum and Dad expecting snow today in Surrey. (Have 5" on the ground here in NJ. And my son's high school in SOCal closed until after Xmas due to fires.)
[Corion]: 1nickt: In a sense the meta-bullshit might even be beneficial to you as you get to hear the cow-orkers talk (or not talk) about the issues you perceive. I think Agile is mostly about the meta ;)
[Corion]: 1nickt: On Sunday maybe 10cm of snow fell, and the airport closed, and the trains stopped running etc :) It always comes as a surprise that snow falls here during the winter...
[marto]: 1nickt, no snow, just some ice on the roads and the usual idiocy associated with humans and driving in less than ideal conditions

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2017-12-11 11:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (289 votes). Check out past polls.

    Notices?