Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   executing commands in the same shell in Windows using Perl (http://www.velocityreviews.com/forums/t895521-executing-commands-in-the-same-shell-in-windows-using-perl.html)

Murugesh 12-07-2005 03:57 AM

executing commands in the same shell in Windows using Perl
 
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

usenet@DavidFilmer.com 12-07-2005 04:38 AM

Re: executing commands in the same shell in Windows using Perl
 
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).


Daniel 12-07-2005 09:27 AM

Re: executing commands in the same shell in Windows using Perl
 
> 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


xhoster@gmail.com 12-07-2005 02:52 PM

Re: executing commands in the same shell in Windows using Perl
 
Murugesh <appumail@gmail.com> 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

xhoster@gmail.com 12-07-2005 02:53 PM

Re: executing commands in the same shell in Windows using Perl
 
usenet@DavidFilmer.com 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

l v 12-07-2005 04:25 PM

Re: executing commands in the same shell in Windows using Perl
 
xhoster@gmail.com wrote:
> Murugesh <appumail@gmail.com> 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



All times are GMT. The time now is 03:53 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.