473,725 Members | 2,295 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

os.system always opens new window on Windows XP/2000

Can anyone tell me how to run a bunch of commands in the same command
line window? When I do this:

system("command 1")
system("command 2")
....

it opens a new window for every system call. The alternative I can
think of is to write out the command to a batch file and run that, but
I'm wondering if there is a better way to do it.

Partly it is annoying to have 20 cmd windows flash on the screen, but
also I don't think it works if I do something like this:

system("set envvar=hi")

since I think the envvar does not persist once the command window is
closed.

thanks!
Jul 18 '05 #1
5 3068

John <oh***********@ yahoo.com> wrote in message
news:d0******** *************** ***@posting.goo gle.com...
Can anyone tell me how to run a bunch of commands in the same command
line window? When I do this:

system("command 1")
system("command 2")
...
If you just want to hide the console window, try
"win32process.C reateProcess"
If you want to set environment variables, I think batch file is OK.

Best Regards,
Kent Hsu

it opens a new window for every system call. The alternative I can
think of is to write out the command to a batch file and run that, but
I'm wondering if there is a better way to do it.

Partly it is annoying to have 20 cmd windows flash on the screen, but
also I don't think it works if I do something like this:

system("set envvar=hi")

since I think the envvar does not persist once the command window is
closed.

thanks!

Jul 18 '05 #2
Is there a reason why there is no way to run all the commands in the same
session? This is how the perl system function or `` works.

MB
If you just want to hide the console window, try
"win32process.C reateProcess"
If you want to set environment variables, I think batch file is OK.

Best Regards,
Kent Hsu

it opens a new window for every system call. The alternative I can
think of is to write out the command to a batch file and run that, but
I'm wondering if there is a better way to do it.

Partly it is annoying to have 20 cmd windows flash on the screen, but
also I don't think it works if I do something like this:

system("set envvar=hi")

since I think the envvar does not persist once the command window is
closed.

thanks!


Jul 18 '05 #3

"Moosebumps " <cr**@crud.co m> wrote in message
news:BV******** ********@newssv r27.news.prodig y.com...
Is there a reason why there is no way to run all the commands in the same
session? This is how the perl system function or `` works.
The system() function is, as the doc says, simply an interface
to the C library's system() function, with all the limitations that
implies.

You could certainly do it if you wanted to, but it's not the
default. You'd have to use one of the popen# functions
in the os module to start a shell and then feed it commands.

As to why it's not there, I suppose nobody has gotten around
to writing it and submitting it for evaluation for inclusion in the
core. That may say something about its perceived utility. Then
again, it may not.

You might want to join the discussion on PEP 324.

John Roth
MB

Jul 18 '05 #4
oh***********@y ahoo.com (John) wrote in message news:<d0******* *************** ****@posting.go ogle.com>...
Can anyone tell me how to run a bunch of commands in the same command
line window? When I do this:

system("command 1")
system("command 2")
...

Use os.popen("comma ndx")
This will return a file-like object from which you can read.
e.g. print os.popen("comma ndx").read()
will give you the console-output of "commandx".
But you must know what you're doing!
e.g. os.popen("comma nd") will start a console-window which
you won't see -- because you used this to avoid a console-window --
and after all I know, there's no chance to come back from this command.
it opens a new window for every system call. The alternative I can
think of is to write out the command to a batch file and run that, but
I'm wondering if there is a better way to do it.

Partly it is annoying to have 20 cmd windows flash on the screen, but
also I don't think it works if I do something like this:

system("set envvar=hi")
This command has no effect. You start a process in whose enviroment
%envvar% exists, but if you don't do anything in the context of this
process after the statement os.system("set envvar=hi") %envvar% will
be forgotten.
Better do: os.environ('env var']= 'hi'
Now the context is your python-script and all you do after this
statement will know %envvar% until your script will exit.

since I think the envvar does not persist once the command window is
closed.
True

thanks!


Regards
Peter
Jul 18 '05 #5
On 6 Jan 2004 10:45:59 -0800, oh***********@y ahoo.com (John) wrote:
Can anyone tell me how to run a bunch of commands in the same command
line window? When I do this:

system("comman d1")
system("comman d2")
...

it opens a new window for every system call. The alternative I can
think of is to write out the command to a batch file and run that, but
I'm wondering if there is a better way to do it.


I would recommend reading a little more about the os, shutil, and
system modules and doing it all in Python. I would especially advise
you to do that if you're seriously considering a batch file instead.
Unless you're going to have people without Python run the same batch
file, you may as well build your script in Python, which is something
it is touted for being good at.
--dang
Jul 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
4964
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my webserver runs that part of the script (see attached file, snippet.php), though, it doesn't go through. I don't get an error message or anything...it just returns a "1" (whereas it should return a "0") as far as I can tell. I have read the PHP...
9
6961
by: none | last post by:
Hello all, I wrote a shell program a few years ago in VB6 that needs to be modified. The problem I have is this: The SysAdmin uses this shell in place of Explorer, so there is no taskbar. When his users run PC Anywhere from the shell, and minimize it, it minimizes to the system tray. With no task bar, there is no system tray, so there is no way to restore the PC Anywhere window. The shell starts PC Anywhere using ShellExecute. I...
3
1707
by: Austin | last post by:
My code is " os.system("NET SEND computer hihi") " i use this funtion on Windows server 2003. it's ok. But the same code running on Windows XP SP2, it shows the command window twice. How do i remove the command window?
3
9141
by: Terrence | last post by:
I am doing some of the C# walkthroughs to transition from VB to C#. When I try to execute static void Main() { Aplication.Run(new Form1()) } I raise a 'System.NullReferenceException" in system.windows.forms.dll
10
4309
by: CyberBless | last post by:
I have a page that opens a child window using window.open(...). How do I make so that when that child window opens you cannot get the focus back on the parent window unless you close the child window? Is it even possible?
4
3769
by: MrMike | last post by:
Hi. I have a hyperlink control (lnkViewLogData) which is assigned the following attribute when the page loads... Me.lnkViewLogData.Attributes.Add("onClick", _ "javascript:window.open('Input_New_Record_CustomerInformation.aspx?CustomerID=" & Me.lblCustomerID.Text & "','myWin','');") As you can see, when this attribute is assigned the hyperlink is formatted to pop open another window. The problem is that when the window opens, it...
0
1174
by: Jeanine | last post by:
Hi, I'm using the webbrowser control in a windows application in vb.net. When you navigate to a site, a new window is always opened. I have read various articles explaining how to use in MDI applications etc, and have tried these things, but still a new window opens when I use the navigate method. I need the browser to stay in the its parent control (ie form or panel control). Is this possible, any suggestions would be most...
4
4484
by: Roger Aikin | last post by:
I've converted a VB6 project to VB.Net 2005. (Actually using vstudio pro 2005). I'm on a machine that also has VB6 and Vstudio.net 2003 on it. The project uses Word, Excel, MapPoint and SqlClient (database is SqlServer 2000). OS is WinXP SP2. When I run the project, it opens the MDI form (MdiMain.vb) fine, but when I open one of the child forms and try to select something in a combo box (cboFilter2) it stops on a line of the...
7
3029
by: Andrew Poulos | last post by:
Is there a way for javascript to know if a browser has been set to open new windows in tabs? I'm trying to fix some code that allows a user to close a window that javascript opened and it seems to get confused what window to close when a new tab is opened. (The user clicks a link in the opened window which which opens a new window and close the current one.) Andrew Poulos
0
8889
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9116
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8099
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.