executing commands in the same shell in Windows using Perl

Discussion in 'Perl Misc' started by Murugesh, Dec 7, 2005.

  1. Murugesh

    Murugesh Guest

    Hi all,
    I need to execute a series a commands inside the same shell in
    Windows.As system() spaws a new shell,how can we do it.
    command1 and command2 should be executed in the same shell unlike the
    following.
    ....
    system("command1");
    system("command2");
    ....

    Appreciate any help on this.

    Thanks,
    Appu
    Murugesh, Dec 7, 2005
    #1
    1. Advertising

  2. Murugesh

    Guest

    Murugesh wrote:
    > I need to execute a series a commands inside the same shell in
    > Windows.As system() spaws a new shell,how can we do it.


    Read the documentation for the function you're using:

    perldoc -f system

    Which will tell you that that's not actually the function you want to
    use (note the discussion about other methods, such as exec and
    BACKTICKS (hint, hint).
    , Dec 7, 2005
    #2
    1. Advertising

  3. Murugesh

    Daniel Guest

    > I need to execute a series a commands inside the same shell in
    > Windows.As system() spaws a new shell,how can we do it.
    > command1 and command2 should be executed in the same shell unlike the
    > following.
    > ...
    > system("command1");
    > system("command2");


    Write all commands into a temporary batch file and then run that. Read
    and use File::Temp and also read what David wrote. He might be right.

    Daniel
    Daniel, Dec 7, 2005
    #3
  4. Murugesh

    Guest

    Murugesh <> wrote:
    > Hi all,
    > I need to execute a series a commands inside the same shell in
    > Windows.As system() spaws a new shell,how can we do it.
    > command1 and command2 should be executed in the same shell unlike the
    > following.
    > ...
    > system("command1");
    > system("command2");
    > ...
    >
    > Appreciate any help on this.


    How do you execute more than one command on the command line on Windows.AS?

    On unix, I do:

    system("command1; command2")
    or
    system("command1\ncommand2")

    Maybe something similar will work with Windows.AS.

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
    , Dec 7, 2005
    #4
  5. Murugesh

    Guest

    wrote:
    > Murugesh wrote:
    > > I need to execute a series a commands inside the same shell in
    > > Windows.As system() spaws a new shell,how can we do it.

    >
    > Read the documentation for the function you're using:
    >
    > perldoc -f system
    >
    > Which will tell you that that's not actually the function you want to
    > use (note the discussion about other methods, such as exec and
    > BACKTICKS (hint, hint).


    I don't see how backticks will help do what the OP wants done. He said
    nothing about capturing the output.

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
    , Dec 7, 2005
    #5
  6. Murugesh

    l v Guest

    wrote:
    > Murugesh <> wrote:
    > > Hi all,
    > > I need to execute a series a commands inside the same shell in
    > > Windows.As system() spaws a new shell,how can we do it.
    > > command1 and command2 should be executed in the same shell unlike the
    > > following.
    > > ...
    > > system("command1");
    > > system("command2");
    > > ...
    > >
    > > Appreciate any help on this.

    >
    > How do you execute more than one command on the command line on Windows.AS?
    >
    > On unix, I do:
    >
    > system("command1; command2")
    > or
    > system("command1\ncommand2")
    >
    > Maybe something similar will work with Windows.AS.
    >
    > Xho
    >


    I've done this before on windows 2000 command line resulting in 3
    appropiate directory listings:
    dir d:\*.* d:\*.txt dir c:\*.*

    Although I do not have this spawning problem on any of my servers
    running Activestate perl, v5.6.1 build 631. What are the commands you
    are running in sequence? Are they truly command line programs? Could
    the programs you call spawn themselves?

    Len
    l v, Dec 7, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kentor

    executing shell commands from c?

    Kentor, Mar 19, 2007, in forum: C Programming
    Replies:
    10
    Views:
    772
    Ben Pfaff
    Mar 20, 2007
  2. mlay

    executing shell commands in asp

    mlay, Nov 9, 2003, in forum: ASP General
    Replies:
    2
    Views:
    182
    Aaron Bertrand [MVP]
    Nov 9, 2003
  3. Kevin Skrenes
    Replies:
    6
    Views:
    207
    Robert Klemme
    Mar 17, 2007
  4. Guilherme Viteri

    Ruby executing shell commands

    Guilherme Viteri, Sep 8, 2010, in forum: Ruby
    Replies:
    2
    Views:
    206
    Roger Pack
    Sep 8, 2010
  5. Nick
    Replies:
    4
    Views:
    129
    C. Olive
    Sep 23, 2003
Loading...

Share This Page