FAQ
hi all,

i am using following command to build the solution file using perl

perl says some error :

following is the error :

Bareword found where operator expected at -e line 1, near "qx/C:\\Program Files\
\Microsoft Visual Studio .NET 2003\\Common7\\IDE\\devenv /rebuild"
syntax error at -e line 1, near "qx/C:\\Program Files\\Microsoft Visual Studio .
NET 2003\\Common7\\IDE\\devenv /rebuild release "
Execution of -e aborted due to compilation errors.

following is the actual command :

L:\Console>perl -e qx/"C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Com
mon7\\IDE\\devenv /rebuild release abc.sln /useenv"/;

plz suggest on how to correctly format the command so that perl can execute that command

this is on windows
plz suggest


--irfan

Search Discussions

  • Shawn H Corey at May 23, 2011 at 12:12 pm

    On 11-05-23 08:02 AM, Irfan Sayed wrote:
    L:\Console>perl -e qx/"C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Com
    mon7\\IDE\\devenv /rebuild release abc.sln /useenv"/;
    L:\Console>perl -e qx/"C:\\Program Files\\Microsoft Visual Studio .NET
    2003\\Common7\\IDE\\devenv \/rebuild release abc.sln /useenv"/;


    --
    Just my 0.00000002 million dollars worth,
    Shawn

    Confusion is the first step of understanding.

    Programming is as much about organization and communication
    as it is about coding.

    The secret to great software: Fail early & often.

    Eliminate software piracy: use only FLOSS.
  • Irfan Sayed at May 23, 2011 at 12:39 pm
    L:\Console>perl -e qx/"C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Com
    mon7\\IDE\\devenv \/rebuild release RMSDC.sln \/useenv"/;
    'C:\Program' is not recognized as an internal or external command,
    operable program or batch file.

    plz suggest;



    ________________________________
    From: Shawn H Corey <shawnhcorey@ncf.ca>
    To: beginners@perl.org
    Sent: Monday, May 23, 2011 5:42 PM
    Subject: Re: proper syntax for command
    On 11-05-23 08:02 AM, Irfan Sayed wrote:
    L:\Console>perl -e qx/"C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Com
    mon7\\IDE\\devenv /rebuild release abc.sln /useenv"/;
    L:\Console>perl -e qx/"C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Common7\\IDE\\devenv \/rebuild release abc.sln /useenv"/;


    -- Just my 0.00000002 million dollars worth,
    Shawn

    Confusion is the first step of understanding.

    Programming is as much about organization and communication
    as it is about coding.

    The secret to great software:  Fail early & often.

    Eliminate software piracy:  use only FLOSS.

    -- To unsubscribe, e-mail: beginners-unsubscribe@perl.org
    For additional commands, e-mail: beginners-help@perl.org
    http://learn.perl.org/
  • Shawn H Corey at May 23, 2011 at 12:54 pm

    On 11-05-23 08:39 AM, Irfan Sayed wrote:
    perl -e qx/"C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Com
    mon7\\IDE\\devenv \/rebuild release RMSDC.sln \/useenv"/;
    perl -e "qx/\"C:\\Program Files\\Microsoft Visual Studio .NET
    2003\\Common7\\IDE\\devenv \/rebuild release RMSDC.sln \/useenv\"/;"


    --
    Just my 0.00000002 million dollars worth,
    Shawn

    Confusion is the first step of understanding.

    Programming is as much about organization and communication
    as it is about coding.

    The secret to great software: Fail early & often.

    Eliminate software piracy: use only FLOSS.
  • Irfan Sayed at May 23, 2011 at 1:17 pm
    L:\Console>perl -e qx-"C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Com
    mon7\\IDE\\devenv /rebuild release abc.sln /useenv"-;
    'C:\Program' is not recognized as an internal or external command,
    operable program or batch file.

    plz suggest



    ________________________________
    From: Christian Marquardt <Christian.Marquardt@trivadis.com>
    To: Irfan Sayed <irfan_sayed2002@yahoo.com>
    Sent: Monday, May 23, 2011 5:45 PM
    Subject: AW: proper syntax for command




    Junk Score: 1 out of 10 (below your Auto Allow threshold)
    Approve sender | Block sender | Block domain
  • Shawn H Corey at May 23, 2011 at 1:39 pm

    On 11-05-23 09:17 AM, Irfan Sayed wrote:
    perl -e qx-"C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Com
    mon7\\IDE\\devenv /rebuild release abc.sln /useenv"-;
    Put the double quotes outside of the entire Perl command:

    perl -e "qx/C:\\Program Files\\Microsoft Visual Studio .NET
    2003\\Common7\\IDE\\devenv \/rebuild release RMSDC.sln \/useenv/;"

    Try copy & pasting the above.


    --
    Just my 0.00000002 million dollars worth,
    Shawn

    Confusion is the first step of understanding.

    Programming is as much about organization and communication
    as it is about coding.

    The secret to great software: Fail early & often.

    Eliminate software piracy: use only FLOSS.
  • Irfan Sayed at May 23, 2011 at 2:04 pm
    hi shawn,
    same error :

    C:\workspace\CCS_Enzo_11\scm>perl -e "qx/\"C:\\Program Files\\Microsoft Visual S
    tudio .NET 2003\\Common7\\IDE\\devenv \/rebuild release RMSDC.sln \/useenv\"/;"
    'C:\Program' is not recognized as an internal or external command,
    operable program or batch file.


    hi christian,

    i want to execute follwoing command using perl

    "C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv" /rebuild release abc.sln /useenv

    plz suggest




    ________________________________
    From: Shawn H Corey <shawnhcorey@ncf.ca>
    To: beginners@perl.org
    Sent: Monday, May 23, 2011 7:09 PM
    Subject: Re: AW: proper syntax for command
    On 11-05-23 09:17 AM, Irfan Sayed wrote:
    perl -e qx-"C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Com
    mon7\\IDE\\devenv /rebuild release abc.sln /useenv"-;
    Put the double quotes outside of the entire Perl command:

    perl -e "qx/C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Common7\\IDE\\devenv \/rebuild release RMSDC.sln \/useenv/;"

    Try copy & pasting the above.


    -- Just my 0.00000002 million dollars worth,
    Shawn

    Confusion is the first step of understanding.

    Programming is as much about organization and communication
    as it is about coding.

    The secret to great software:  Fail early & often.

    Eliminate software piracy:  use only FLOSS.

    -- To unsubscribe, e-mail: beginners-unsubscribe@perl.org
    For additional commands, e-mail: beginners-help@perl.org
    http://learn.perl.org/
  • Rob Dixon at May 23, 2011 at 2:24 pm

    On 23/05/2011 13:02, Irfan Sayed wrote:
    hi all,

    i am using following command to build the solution file using perl

    perl says some error :

    following is the error :

    Bareword found where operator expected at -e line 1, near "qx/C:\\Program Files\
    \Microsoft Visual Studio .NET 2003\\Common7\\IDE\\devenv /rebuild"
    syntax error at -e line 1, near "qx/C:\\Program Files\\Microsoft Visual Studio .
    NET 2003\\Common7\\IDE\\devenv /rebuild release "
    Execution of -e aborted due to compilation errors.

    following is the actual command :

    L:\Console>perl -e qx/"C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Com
    mon7\\IDE\\devenv /rebuild release abc.sln /useenv"/;

    plz suggest on how to correctly format the command so that perl can execute that command

    this is on windows
    plz suggest
    Hi Irfan.

    Try this

    perl -e "qx{\"C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\devenv\" /rebuild release RMSDC.sln /useenv}"

    (Although I don't understand why you need to execute the command through
    Perl instead of directly.)

    Rob
  • Irfan Sayed at May 23, 2011 at 2:32 pm
    Hi Rob,
    thanks.

    my entire build script is in perl and i want this command to be executed in perl

    so please let me know what is the best way to execute this command in perl

    --irfan



    ________________________________
    From: Rob Dixon <rob.dixon@gmx.com>
    To: Perl Beginners <beginners@perl.org>
    Cc: Irfan Sayed <irfan_sayed2002@yahoo.com>
    Sent: Monday, May 23, 2011 7:55 PM
    Subject: Re: proper syntax for command
    On 23/05/2011 13:02, Irfan Sayed wrote:
    hi all,

    i am using following command to build the solution file using perl

    perl says some error :

    following is the error :

    Bareword found where operator expected at -e line 1, near "qx/C:\\Program Files\
    \Microsoft Visual Studio .NET 2003\\Common7\\IDE\\devenv /rebuild"
    syntax error at -e line 1, near "qx/C:\\Program Files\\Microsoft Visual Studio .
    NET 2003\\Common7\\IDE\\devenv /rebuild release "
    Execution of -e aborted due to compilation errors.

    following is the actual command :

    L:\Console>perl -e qx/"C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Com
    mon7\\IDE\\devenv /rebuild release abc.sln /useenv"/;

    plz suggest on how to correctly format the command so that perl can execute that command

    this is on windows
    plz suggest
    Hi Irfan.

    Try this

    perl -e "qx{\"C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\devenv\" /rebuild release RMSDC.sln /useenv}"

    (Although I don't understand why you need to execute the command through
    Perl instead of directly.)

    Rob

    --
    To unsubscribe, e-mail: beginners-unsubscribe@perl.org
    For additional commands, e-mail: beginners-help@perl.org
    http://learn.perl.org/
  • Rob Dixon at May 23, 2011 at 2:44 pm

    On 23/05/2011 15:32, Irfan Sayed wrote:
    From: Rob Dixon<rob.dixon@gmx.com>
    Sent: Monday, May 23, 2011 7:55 PM
    On 23/05/2011 13:02, Irfan Sayed wrote:

    i am using following command to build the solution file using perl

    perl says some error :

    following is the error :

    Bareword found where operator expected at -e line 1, near "qx/C:\\Program Files\
    \Microsoft Visual Studio .NET 2003\\Common7\\IDE\\devenv /rebuild"
    syntax error at -e line 1, near "qx/C:\\Program Files\\Microsoft Visual Studio .
    NET 2003\\Common7\\IDE\\devenv /rebuild release "
    Execution of -e aborted due to compilation errors.

    following is the actual command :

    L:\Console>perl -e qx/"C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Com
    mon7\\IDE\\devenv /rebuild release abc.sln /useenv"/;

    plz suggest on how to correctly format the command so that perl can execute that command

    this is on windows
    plz suggest
    Hi Irfan.

    Try this

    perl -e "qx{\"C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\devenv\" /rebuild release RMSDC.sln /useenv}"

    (Although I don't understand why you need to execute the command through
    Perl instead of directly.)
    my entire build script is in perl and i want this command to be executed in perl

    so please let me know what is the best way to execute this command in perl
    I would write it as below.

    HTH,

    Rob


    use strict;
    use warnings;

    use autodie 'system';

    my $devenv = 'C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv';

    my $status = system($devenv, '/rebuild release abc.sln', '/useenv');
  • Irfan Sayed at May 23, 2011 at 5:01 pm
    i tried this code, but in actual it is not executing the solution file.
    instead, it is opening the solution file and saying /rebuild release file not found

    plz suggest . i am really stuck



    ________________________________
    From: Rob Dixon <rob.dixon@gmx.com>
    To: Perl Beginners <beginners@perl.org>
    Cc: Irfan Sayed <irfan_sayed2002@yahoo.com>
    Sent: Monday, May 23, 2011 8:16 PM
    Subject: Re: proper syntax for command




    You chose to allow Rob Dixon (rob.dixon@gmx.com) even though this message failed authentication
    Click to disallow
  • Jim Gibson at May 24, 2011 at 2:42 am

    At 10:01 AM -0700 5/23/11, Irfan Sayed wrote:
    i tried this code, but in actual it is not executing the solution file.
    instead, it is opening the solution file and saying /rebuild release
    file not found

    plz suggest . i am really stuck
    Please show us the code you tried and the exact error message. Cut
    and paste the code and output, do not retype.

    I believe you are trying to run an external executable from a Perl
    program. Please also show us the command-line version that does what
    you want. You should be able to package that exact line in a call to
    system, but try it from the same directory where the Perl program
    resides.
  • Irfan Sayed at May 24, 2011 at 6:17 am
    here is the actual code:

    use strict;
    use warnings;
    use Cwd;
    chdir "L:\\Console";
    my $dir = getcwd();
    print "current dir is : $dir\n";
    my $res = system("dir");
    $res=system("devenv","/rebuild","release","abc.sln","/useenv");
    print "$res\n";


    now, the issue is , at last the value of $res is 256 instead of the real output of command.
    just to give details, devenv is the compiler which compiles the solution file. i need to compile the solution file abc.sln and print the entire output of command on the console


    pls suggest
    --irf


    ________________________________
    From: Jim Gibson <jimsgibson@gmail.com>
    To: Perl Beginners <beginners@perl.org>
    Sent: Tuesday, May 24, 2011 9:19 AM
    Subject: Re: proper syntax for command




    You chose to allow Jim Gibson (jimsgibson@gmail.com) even though this message failed authentication
    Click to disallow
  • Kenneth Wolcott at May 24, 2011 at 6:28 am

    On Mon, May 23, 2011 at 23:17, Irfan Sayed wrote:
    here is the actual code:

    use strict;
    use warnings;
    use Cwd;
    chdir "L:\\Console";
    my $dir = getcwd();
    print "current dir is : $dir\n";
    my $res = system("dir");
    $res=system("devenv","/rebuild","release","abc.sln","/useenv");
    print "$res\n";


    now, the issue is , at last the value of $res is 256 instead of the real output of command.
    just to give details, devenv is the compiler which compiles the solution file. i need to compile the solution file abc.sln and print the entire output of command on the console


    pls suggest
    --irf
    I didn't do "Replay-all" :-()

    n place of "system", try using back-quiotes (known as grave with an
    accent from the French) to "execute the statement and preserve the
    output". Or use the "qx" operator. The results of the command should
    be assigned to the variable. Do you have a verbose option for your
    compiler call?

    Hope this helps,
    Ken Wolcott
  • Jim Gibson at May 24, 2011 at 6:34 am

    At 11:17 PM -0700 5/23/11, Irfan Sayed wrote:
    here is the actual code:

    use strict;
    use warnings;
    use Cwd;
    chdir "L:\\Console";
    my $dir = getcwd();
    print "current dir is : $dir\n";
    my $res = system("dir");
    $res=system("devenv","/rebuild","release","abc.sln","/useenv");
    print "$res\n";

    now, the issue is , at last the value of $res is 256 instead of the
    real output of command.
    just to give details, devenv is the compiler which compiles the
    solution file. i need to compile the solution file abc.sln and print
    the entire output of command on the console
    The system function returns an error or success value. The standard
    output of the command executed by system should end up on your
    terminal.

    If you want to capture the output of the command, use backticks or
    the qx operator:

    my @output = qx( devenv /rebuild release abc.sln /useenv);

    See 'perldoc -q system' "Why can't I get the output of a command with
    system()?"
    and 'perldoc -f system'.
  • Brandon McCaig at May 24, 2011 at 9:04 pm

    On Mon, May 23, 2011 at 8:02 AM, Irfan Sayed wrote:
    L:\Console>perl -e qx/"C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Com
    mon7\\IDE\\devenv /rebuild release abc.sln /useenv"/;

    plz suggest on how to correctly format the command so that perl can execute that command
    I'm guessing that the main problem is the Windows shell's awkward
    syntax. :) I've been trying for years to make sense of it and I still
    can't. :) Try this:

    perl -e "print qx'C:\Program^ Files\Microsoft^ Visual^ Studio^ .NET^
    2003\Common7\IDE\devenv /rebuild release abc.sln /useenv'"

    In order to come up with that I needed to write a C program to be sure
    arguments were being passed as I expected, then once I was sure how
    arguments were going to be passed I had to play with perl to figure
    out the solution. :P

    <<<
    #include <stdio.h>

    int main(int argc, char * argv[])
    {
    int i;

    for(i=0; i<argc; i++)
    printf("%d=%s\n", i, argv[i]);

    return 0;
    }
    >>>

    Compile with MinGW with a command like this:

    gcc -Wall main.c -o args.exe

    Then test the arguments you're passing:

    args Whatever you want here

    The output should show you which string is in which argument slot. :)

    cmd.exe is really weird. While ^ is supposed to be the escape
    character, it seems to only escape certain special characters. As far
    as I can tell you can't escape white-space.

    args foo^ bar

    Outputs:

    0=args
    1=foo
    2=bar

    That forces you to use double-quotes (single-quotes mean nothing
    AFAIK) when an argument contains spaces, but then if you also need
    embedded double-quotes then you need to double them to escape them
    (instead of using ^" you have to use ""). Then, according to my
    experiments, the escaped double-quote also terminates the quoted
    string (which makes zero sense) so you have to start again with a new
    double-quote if the rest of the argument contains any spaces... The
    Windows graphical shell might be somewhat refined (in some other
    people's opinion), but the Windows command shell is certainly not.

    Once I had that figured out I tried to invoke my args C program using
    the same rules:

    perl -e "print qx'"""C:\Documents and Settings\bamccaig\args.exe"""
    /rebuild release abc.sln /useenv'"

    Low and behold, that does NOT work. The Windows shell complains that
    "C:\Documents and Settings\bamccaig\args.exe" (WITH the double-quotes)
    is not found (as an aside, I originally wrote the args program as a
    batch file and got the quotes as well). :P Through experimentation, I
    discovered that you can escape the whitespace using ^ here though
    (again, completely doesn't make sense based on the cmd.exe interface),
    which gives me:

    perl -e "print qx'C:\Documents^ and^ Settings\bamccaig\args.exe
    /rebuild release abc.sln /useenv'"

    Which outputs:

    0=C:\Documents
    1=and
    2=Settings\bamccaig\args.exe
    3=/rebuild
    4=release
    5=abc.sln
    6=/useenv

    Which ALSO doesn't make sense! Clearly my C program is being invoked
    (the output is in the expected format), but the program itself thinks
    that its path is three arguments, not one. Don't ask me how Microsoft
    can achieve such epic failure, but they don't seem to have any trouble
    at all. My advice is to simply not use Microsoft Windows if you need
    software to work reliably, but I digress...

    I can't promise that I didn't make any mistakes in writing this E-mail
    and testing the various ways. It makes such little sense that it's
    very easy to drive yourself crazy and confuse yourself. :P


    --
    Brandon McCaig <http://www.bamccaig.com/> <bamccaig@gmail.com>
    V zrna gur orfg jvgu jung V fnl. Vg qbrfa'g nyjnlf fbhaq gung jnl.
    Castopulence Software <http://www.castopulence.org/> <bamccaig@castopulence.org>
  • Brandon McCaig at May 24, 2011 at 9:06 pm

    On Tue, May 24, 2011 at 5:03 PM, Brandon McCaig wrote:
    perl -e "print qx'C:\Program^ Files\Microsoft^ Visual^ Studio^ .NET^
    2003\Common7\IDE\devenv /rebuild release abc.sln /useenv'"
    This should of course be one line (with a space between the ^ and the 2).
    perl -e "print qx'"""C:\Documents and Settings\bamccaig\args.exe"""
    /rebuild release abc.sln /useenv'"
    This should of course be one line (with a space between the " and /).
    perl -e "print qx'C:\Documents^ and^ Settings\bamccaig\args.exe
    /rebuild release abc.sln /useenv'"
    This should of course be one line (with a space between the e and /).

    I should possibly note too that I did these tests in a Windows XP VM
    so YMMV. Maybe the behavior has improved in Vista or Seven, but I
    doubt it. ;D

    --
    Brandon McCaig <http://www.bamccaig.com/> <bamccaig@gmail.com>
    V zrna gur orfg jvgu jung V fnl. Vg qbrfa'g nyjnlf fbhaq gung jnl.
    Castopulence Software <http://www.castopulence.org/> <bamccaig@castopulence.org>

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupbeginners @
categoriesperl
postedMay 23, '11 at 12:02p
activeMay 24, '11 at 9:06p
posts17
users6
websiteperl.org

People

Translate

site design / logo © 2021 Grokbase