Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > executing commands in the same shell in Windows using Perl

Reply
Thread Tools

executing commands in the same shell in Windows using Perl

 
 
Murugesh
Guest
Posts: n/a
 
      12-07-2005
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
 
Reply With Quote
 
 
 
 
usenet@DavidFilmer.com
Guest
Posts: n/a
 
      12-07-2005
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).

 
Reply With Quote
 
 
 
 
Daniel
Guest
Posts: n/a
 
      12-07-2005
> 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

 
Reply With Quote
 
xhoster@gmail.com
Guest
Posts: n/a
 
      12-07-2005
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
 
Reply With Quote
 
xhoster@gmail.com
Guest
Posts: n/a
 
      12-07-2005
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
 
Reply With Quote
 
l v
Guest
Posts: n/a
 
      12-07-2005
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ruby executing shell commands Guilherme Viteri Ruby 2 09-08-2010 08:09 PM
executing shell commands from c? Kentor C Programming 10 03-20-2007 04:00 PM
Executing shell commands from Ruby... again. Kevin Skrenes Ruby 6 03-17-2007 09:00 AM
executing shell commands in asp mlay ASP General 2 11-09-2003 03:25 PM
Perl: how to stop users from executing commands from browser Nick Perl Misc 4 09-23-2003 07:20 PM



Advertisments
 



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