473,548 Members | 2,683 Online
Bytes | Software Development & Data Engineering Community
+ 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 4327
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 , """Category Y = 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 , """Category Y = 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 , """Category Y = 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
9127
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 requiring a long, long formatted arglist via (%s,%s,%s,ad infinitum) if there is. So my question is: Is there a way to produce a very long...
8
4339
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 different various locations. I've checked the versions of browsers and I've tried from at least 10 different pc's in different locations and the page...
3
1266
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 Ranbir
0
1399
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 errors like this "operations must use an updateable query" here is the form part:- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"...
5
2026
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 insert the date to the calling page I get the error "A runtime error has occured Line 14
11
2420
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 side and HTTP is the bridge between client and server and it works in whole pages at a time. (One request -> complete response)" But _it is...
9
1303
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 = "lbug.gif") { document.Form1.imgBug.src = "stopbug.jpg"; } else if (document.Form1.imgBug.src = "stopbug.jpg")
5
11120
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 But the title is inside the head so why I am getting this?
1
1863
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 1st and the value entered in 3rd must not b the value entered in 1st,2nd etc.. like this. Please tell me how it can be done. I'm sending the code...
4
1437
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
7438
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...
0
7707
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. ...
1
7466
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
7803
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
6036
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...
1
5362
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...
0
3495
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1926
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
1051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.