executing commands in the same shell in Windows using Perl

M

Murugesh

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
 
U

usenet

Murugesh said:
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).
 
D

Daniel

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
 
X

xhoster

Murugesh said:
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
 
X

xhoster

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
 
L

l v

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top