473,577 Members | 3,341 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to pass a multiline arg to exec('some.exe arg')?

os:windows
ml = 'line1 \n line2 \n line3 \n'
exec('some.exe "' + ml + '"')

and some.exe get only 'line1'...
Jun 27 '08 #1
4 1847
Hint:
for some reason in VBScript it works fine.
What makes it different, with Python?
I tried all possible ways to combine quotes, ' and ",
with no avail
Jun 27 '08 #2
On May 5, 10:25 am, n00m <n...@narod.ruw rote:
os:windows
ml = 'line1 \n line2 \n line3 \n'
exec('some.exe "' + ml + '"')

and some.exe get only 'line1'...
I think your problem lies with your "\n", escape chars. Assuming these
are not arguments and are indeed separating statements, I suggest
replacing "\n", with "&". That way, the command shell probably wont
complain.

An example:
ml = 'line1 & line2 & line3'

Alex.
Jun 27 '08 #3
n00m wrote:
os:windows
ml = 'line1 \n line2 \n line3 \n'
exec('some.exe "' + ml + '"')

and some.exe get only 'line1'...
My crystall ball says you want

subprocess.call (["some.exe", ml])

exec is a python statement that executes python code.

Peter
Jun 27 '08 #4
actually, it's this doesn't work (again, in VBS the "same"
construction works properly):

f = os.popen('osql -E -S(local) -dpubs -w800 -Q"' + query + '"', 'r')

res=f.readlines ()

=======
here "query" is a multiline string like:

select getdate()

select 555*666

select getdate()
Jun 27 '08 #5

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

Similar topics

1
9028
by: aa | last post by:
Anybody know the solution to trailing space in argument of Runtime.getRuntime().exec(arg), Process p = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler C:\\Documents and Settings\\XX\\Desktop\\- Copy of TestingFolder -\\jjjj hihi.doc"); where there is 2 space between dash and "Copy of TestingFolder", but after going...
5
2225
by: Didier C | last post by:
Hi! I was wondering if we can pass some arguments to system("cmdline")? E.g in Perl, we can do something like: $dir="/home/cypher"; system("ls $dir"); which would instruct Perl to do an "ls /home/cypher"
4
4540
by: Todd | last post by:
Is it possible to pass an argument by reference through an event in C++ managed code? For example, can I do the following? public __gc class MyClass : public Control { public: __event void MyEvent(bool &Cancel);
0
2471
by: Korol | last post by:
I need to pass some value from XSL to javascript. For the reasons it is inpossible to use xsl:param and xsl:variable. There is some ‘if’ conditions in XSL that would modify that value. I create id in my HTML. <TABLE ALIGN ID="Table2"> <TR> <td id="hasValue"/> </TR> </TABLE>
1
1211
by: mehdi_mousavi | last post by:
Hi, I need to pass some variables to a given web user ctrl, say, myctrl.ascx. e.g., I need to include the user control within a web form as follows: myctrl.ascx?myparam=myvalue&whatever=another_value whilst somewhere else I would call the mentioned ctrl as myctrl.ascx?myparam2=myvalue&whatever2=another_value
2
1611
by: Joel | last post by:
Hey there.. I'm using boa constructor to debug a python application. For my application, I need to insert break points and execute some piece of code interactively through shell or someother window when the breakpoint has been reached. Unfortunately the shell I think is a seperate process so whatever variables are set while executing in...
2
3505
indianmaestro
by: indianmaestro | last post by:
Hi i want to display some text on the label when i select an item int he listbox. for this i have written some code which is workint fine in the InternetEplore but when it comes to mozilla the text not showing my coding is like this document.getElementById('<%=lblcnt.ClientID%>').innerText="1 Student(s) selected"; help me
0
854
by: n00m | last post by:
No, it would be too easy & simple. While stdin is NOT CLOSED stdout has not EOF, but readlines() waits for its appearence ... and so freezes for good. IMO. Should be like this: import popen2 o=popen2.popen2('osql -E -S(local) -dpubs -c"GO" -n -w8000') while 1: o.write(raw_input()+'\nGO\n') o.flush() # this line can be commented
14
3599
by: =?Utf-8?B?Umljaw==?= | last post by:
I have seen examples of passing data from FormB to FormA (Parent To Child) but I need an example of passind data from FormA to FormB. My main form is FormA; I will enter some data in textboxes and click a button to bring up FormB which needs to display values entered in FormA. Thanks in advance.
0
8123
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8289
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...
1
7870
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8145
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...
0
6519
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...
0
5341
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...
1
2292
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1388
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1111
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...

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.