system command question

Ask a Question related to PERL Miscellaneous, Design and Development.

  1. #1

    Default system command question

    I there a reason why a command will not work if i do system "$cmd &>
    xyz.log" even though it works if I do system "$cmd"
    Himal Guest

  2. Similar Questions and Discussions

    1. Displaying part of HTML before and after system() command
      Consider my (simplified) code below: With my old ISP it used to display "Archiving database images ..." then paused for a while (30 secs to a few...
    2. Problem with the Perl System command
      Hi, I am facing an issue with the perl system command The relevant lines of code are the following: chdir "$util"; my @args =...
    3. configuring system DSN from command line Linux
      Hello, I have a linux software (runs on mysql) for which i need to configure systemDSN and device driver. I have been configuring SystemDSN...
    4. what command to view system configuration?
      hi all. I forgot command to see al system parameter ... for example: i used it to see firmware release. Bye. -- Massimiliano
    5. calling system command as another user
      Howdy People, I am not a Perl guy and have to make some code work. We have a password reset facility that is Perl cgi based and simply generates...
  3. #2

    Default Re: system command question

    Himal wrote:
    > I there a reason why a command will not work if i do system "$cmd &>
    > xyz.log" even though it works if I do system "$cmd"
    This is an OS/Shell issue.

    From your command line try:

    whateverCommandYouAreTryingToRun & > xyz.log

    and you should see the error.

    J. Gleixner Guest

  4. #3

    Default Re: system command question

    Himal wrote:
    > I there a reason why a command will not work if i do system "$cmd &>
    > xyz.log" even though it works if I do system "$cmd"
    Most likely, the shell perl is using to parse your command is
    not csh. Exactly why this is so would depend on your configuration.
    Try this, which will work for sh/ksh/bash: system "$cmd >xyz.log 2>&1"

    Chris Mattern

    Chris Mattern Guest

  5. #4

    Default Re: system command question

    In article <3F61EB8C.8000604@gwu.edu>, Chris Mattern wrote:
    > Himal wrote:
    >> I there a reason why a command will not work if i do system "$cmd &>
    >> xyz.log" even though it works if I do system "$cmd"
    >
    > Most likely, the shell perl is using to parse your command is
    > not csh. Exactly why this is so would depend on your configuration.
    > Try this, which will work for sh/ksh/bash: system "$cmd >xyz.log 2>&1"
    There is no reason for it to be csh. The manual for the system
    command says:

    If there is only one scalar argument, the argument is
    checked for shell metacharacters, and if there are any, the
    entire argument is passed to the system's command shell for
    parsing (this is "/bin/sh -c" on Unix platforms, but varies
    on other platforms). If there are no shell metacharacters
    in the argument, it is split into words and passed directly
    to "execvp", which is more efficient.

    So it's either /bin/sh (on Unix systems) or no shell at all.,
    if you haven't done some pretty freakish changes in the default
    configuration.

    --
    Andreas Kähäri
    Andreas Kahari Guest

  6. #5

    Default Re: system command question

    Andreas Kahari wrote:
    > In article <3F61EB8C.8000604@gwu.edu>, Chris Mattern wrote:
    >
    >>Himal wrote:
    >>
    >>>I there a reason why a command will not work if i do system "$cmd &>
    >>>xyz.log" even though it works if I do system "$cmd"
    >>
    >>Most likely, the shell perl is using to parse your command is
    >>not csh. Exactly why this is so would depend on your configuration.
    >>Try this, which will work for sh/ksh/bash: system "$cmd >xyz.log 2>&1"
    >
    >
    > There is no reason for it to be csh. The manual for the system
    > command says:
    >
    > If there is only one scalar argument, the argument is
    > checked for shell metacharacters, and if there are any, the
    > entire argument is passed to the system's command shell for
    > parsing (this is "/bin/sh -c" on Unix platforms, but varies
    > on other platforms). If there are no shell metacharacters
    > in the argument, it is split into words and passed directly
    > to "execvp", which is more efficient.
    >
    > So it's either /bin/sh (on Unix systems) or no shell at all.,
    > if you haven't done some pretty freakish changes in the default
    > configuration.
    >
    Ah, OK, I thought it used the user's shell. OK, then,
    system "$cmd >xyz.log 2>&1" should be the answer, assuming
    the OP is on a Unix system (which seems logical, since he's
    trying to use csh syntax).

    Chris Mattern

    Chris Mattern Guest

  7. #6

    Default Re: system command question

    Chris Mattern <syscjm@gwu.edu> wrote in comp.lang.perl.misc:
    > Andreas Kahari wrote:
    > > In article <3F61EB8C.8000604@gwu.edu>, Chris Mattern wrote:
    > >
    > >>Himal wrote:
    > >>
    > >>>I there a reason why a command will not work if i do system "$cmd &>
    > >>>xyz.log" even though it works if I do system "$cmd"
    [...]
    > Ah, OK, I thought it used the user's shell. OK, then,
    > system "$cmd >xyz.log 2>&1" should be the answer, assuming
    > the OP is on a Unix system (which seems logical, since he's
    > trying to use csh syntax).
    Except that he isn't. "$cmd >& xyz.log" would be csh syntax.
    "$cmd &> xyz.log" is neither here nor there.

    Anno
    Anno Siegel Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139