in reply to use Shell

Irrespective of the syntax problem, this approach isn't going to work anyway, because mail is not a shell built-in.  In other words, the shell itself cannot send mail. So, unless you have some shell-external program or module installed that will do the actual sending, you won't have much luck sending mail that way...

Replies are listed 'Best First'.
Re^2: use Shell
by Jenda (Abbot) on Mar 09, 2010 at 15:32 UTC

    It doesn't have to be a built-in. Actually if it was, it would be much less likely to work.

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.

      What I wanted to point out is that if there is no built-in called "mail", all a shell will do is try to invoke an external program of that name.

      From the OP mentioning that there is no sendmail etc. installed (which mail would by default use as MTA), I figured that there most likely also is no working mail command available...  In short, the Shell module alone then won't help with sending mail — which, as I understand, is what the OP was trying to achieve.

      Update:

      if it was (a built-in), it would be much less likely to work.

      From a quick try it looks like the module has no problems running shell built-ins, as long as there are shell metacharacters in the arguments. Otherwise, the string is split and passed as separate arguments directly to the system call execve, thus bypassing the shell.  (In other words, it seems the same rules as with system and friends apply.)

      #!/usr/bin/perl use Shell qw(echo); echo "foo bar ;"; # with ";" --> uses 'echo' shell built-in echo "foo bar"; # uses /bin/echo

      (from strace -f output)

      (echo "foo bar ;") ... [pid 23888] execve("/bin/sh", ["sh", "-c", "echo foo bar ;"], ... (echo "foo bar") ... [pid 23889] execve("/bin/echo", ["echo", "foo", "bar"], ...