473,480 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

here document

L.S.,

Would somebody help me how i can write the 'here document' in
Python script please? I have a csh script in which a program
is invoked with some argument in the form of here document:

/bin/exe.x << End_Here
CategorY = GRIB
etc.
End_Here

I translate this script to Python and i don't know how can I
do this!

with regards,
Nader
Jul 18 '05 #1
3 4323
On 11.01.2005, at 11:34, Nader Emami wrote:
Would somebody help me how i can write the 'here document' in
Python script please? I have a csh script in which a program
is invoked with some argument in the form of here document:

/bin/exe.x << End_Here
CategorY = GRIB
etc.
End_Here

I translate this script to Python and i don't know how can I
do this!


f = open("/bin/exe.x","w")
print >>f , """CategoryY = GRIB
etc.
"""

--
What if nothing exists and everything is an illusion?
In this case I definitely overpayed my new carpet!
-- Woody Allen

Jul 18 '05 #2
harold fellermann wrote:
f = open("/bin/exe.x","w")
print >>f , """CategoryY = GRIB
etc.
"""


This would overwrite the existing /bin/exe.x ...

HtH, Roland
Jul 18 '05 #3
On Tue, 2005-01-11 at 18:46, harold fellermann wrote:
On 11.01.2005, at 11:34, Nader Emami wrote:
Would somebody help me how i can write the 'here document' in
Python script please? I have a csh script in which a program
is invoked with some argument in the form of here document:

/bin/exe.x << End_Here
CategorY = GRIB
etc.
End_Here

I translate this script to Python and i don't know how can I
do this!


f = open("/bin/exe.x","w")
print >>f , """CategoryY = GRIB
etc.
"""


You mean "os.popen" not "open" I assume? The former opens a pipe to a
command, the latter overwrites the file.

I'd use:

os.popen("/bin/exe.x", "w").write("""\
CategorY = GRIB
etc.
""")
myself, but that's just taste (well, and performance I suspect).

--
Craig Ringer

Jul 18 '05 #4

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

Similar topics

33
9110
by: Jim Hill | last post by:
I've done some Googling around on this and it seems like creating a here document is a bit tricky with Python. Trivial via triple-quoted strings if there's no need for variable interpolation but...
8
4322
by: David Girard | last post by:
I'm getting the following error which is no big deal - the problem is it is LOCATION specific - which has me really baffled... for some reason the error only appears on different machines in...
3
1259
by: Ranbir Kaur | last post by:
Hi all, http://www.gurmatps.org works fine in MSIE6, Opera7, NS7 (for windows) Could someone do me the favor and check what may be wrong that it doesn't display right in MAC browsers? Thanks...
0
1396
by: webweaver_khries | last post by:
here is a piece of form field and an asp action codes so the thing is when i started working on this, at first it was working but after i formatted my c drive of my computer. i started recieving...
5
2022
by: Chris | last post by:
Hi, I have been trying for days, yes days, to use the calender from the asp.net timetracker starter kit. I am now frustrated. I finally get the popup calender to popup but when I click ok to...
11
2415
by: Peter Fox | last post by:
A FAQ here goes something like "How can I get input from the middle of my form sent processed to PHP and the result returned to the page?" The standard answer is "You can't because PHP is server...
9
1298
by: Marc Miller | last post by:
I have an html img with a source of 'lbug.gif'. I want to be able to change out the source of the img by clicking a button. Here's my code: function swapPic() { if (document.Form1.imgBug.src...
5
11110
by: garfy | last post by:
Hi i get this error in validation Line 22 column 6: document type does not allow element "title" here. <title>Seo Web Design Los Angeles - Web Design And Search Engine Optimization L ...
1
1852
by: anilareddy | last post by:
I have an application like this. I need to validate the start time in 2nd row against the start row in first row. I mean The start time value entered in the second row must not b the value entered in...
4
1434
by: Bjorndal | last post by:
I'm new to javascript, so I figure som of you guys in here can answer my question pretty easily: I have this code which works: <script type="text/javascript"> </script> </head> <body>
0
7054
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,...
0
7102
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...
1
6756
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...
0
7003
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...
1
4798
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...
0
3000
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1310
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 ...
1
570
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
199
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...

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.