Loading ...
Sorry, an error occurred while loading the content.

using BackTicks in perl

Expand Messages
  • Raja Rajasekaram
    Hi All, Anyone used backticks in Perl? Here is what I am trying to do $x = `mkdir /mnt`; print $x ; Is there anyway to catch the output? Or does backticks
    Message 1 of 3 , Dec 12, 2006
    • 0 Attachment
      Hi All,

      Anyone used backticks in Perl? Here is what I am trying to do
      $x = `mkdir /mnt`;
      print "$x";

      Is there anyway to catch the output? Or does backticks return anything?

      Thanks





      ____________________________________________________________________________________
      Do you Yahoo!?
      Everyone is raving about the all-new Yahoo! Mail beta.
      http://new.mail.yahoo.com

      [Non-text portions of this message have been removed]
    • merlyn@stonehenge.com
      ... Raja Hi All, Raja Anyone used backticks in Perl? Here is what I am trying to do Raja $x = `mkdir /mnt`; Why are you using external mkdir when Perl has a
      Message 2 of 3 , Dec 12, 2006
      • 0 Attachment
        >>>>> "Raja" == Raja Rajasekaram <raja_rajasekaram@...> writes:

        Raja> Hi All,
        Raja> Anyone used backticks in Perl? Here is what I am trying to do
        Raja> $x = `mkdir /mnt`;

        Why are you using external mkdir when Perl has a mkdir already?
        Faster, cheaper, more portable. Hard to beat.

        Raja> print "$x";

        Raja> Is there anyway to catch the output? Or does backticks return anything?

        That's catching stdout. Maybe the external command is generating stderr.

        --
        Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
        <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
        Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
        See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
      • Rob Biedenharn
        ... What else have you tried? What does this give you: $x = `pwd`; print $x; What did you expect to find in $x after $x=`mkdir /mnt`; ? -Rob Rob Biedenharn
        Message 3 of 3 , Dec 12, 2006
        • 0 Attachment
          On Dec 12, 2006, at 11:15 AM, Raja Rajasekaram wrote:

          > Hi All,
          >
          > Anyone used backticks in Perl? Here is what I am trying to do
          > $x = `mkdir /mnt`;
          > print "$x";
          >
          > Is there anyway to catch the output? Or does backticks return
          > anything?
          >
          > Thanks

          What else have you tried?

          What does this give you:
          $x = `pwd`;
          print $x;

          What did you expect to find in $x after $x=`mkdir /mnt`; ?

          -Rob

          Rob Biedenharn http://agileconsultingllc.com
          Rob@...
        Your message has been successfully submitted and would be delivered to recipients shortly.