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

Re: [PBML] awk in perl script

Expand Messages
  • Shlomi Fish
    Hi B., On Tue, 17 Jan 2012 09:46:04 +0100 ... Here you open the door to code injection: http://shlomif-tech.livejournal.com/35301.html Please look at
    Message 1 of 2 , Jan 17, 2012
    • 0 Attachment
      Hi B.,

      On Tue, 17 Jan 2012 09:46:04 +0100
      sin@... wrote:

      > Hi,
      >
      > First of all I want say Hello because I'm newbie in perl and new on this
      > list.
      >
      > I can't solve one problem. I wish you will help me.
      > I have perl script that is running by crontab:
      >
      > my $reply = `echo '$message'|$gnokii --sendsms $number`;

      Here you open the door to code injection:

      http://shlomif-tech.livejournal.com/35301.html

      Please look at http://search.cpan.org/dist/IPC-Run/ for a good solution for
      that.

      > chomp($reply);
      > my $reply1 = `system ( "echo '$reply' | awk '{print \$1\$2}'" )`;
      >

      system ( ... ) is not a shell command. Doing `system ( ... )` is usually
      wrong. Aside from that, you usually shouldn't invoke awk code from within Perl
      because Perl gives you similar routines in the language itself. Look at
      http://perldoc.perl.org/functions/split.html and see http://perl-begin.org/ .

      > First line (gnokii command) returns a few columns with space separator. I
      > want that $reply1 have only first and second column from $reply without
      > space. I wrote:
      > my $reply1 = `system ( "echo '$reply' | awk '{print \$1\$2}'" )`;
      > but it doesn't working. Somewhere is syntax error or/and other defect. Pls
      > help!

      Regards,

      Shlomi Fish

      --
      -----------------------------------------------------------------
      Shlomi Fish http://www.shlomifish.org/
      Interview with Ben Collins-Sussman - http://shlom.in/sussman

      Jewish Atheists are the only true Atheists. They beat the hell out of Goy
      Atheists.

      Please reply to list if it's a mailing list post - http://shlom.in/reply .
    Your message has been successfully submitted and would be delivered to recipients shortly.