473,700 Members | 2,743 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I need some advice/help on running my scripts

For the last couple of months I have been reading and working throught
the examples in Magnus Lie Hetland's Book "Practical Python" This for
all practical purposes is the first computer programming language I
have spent any time at learning, so much of what I have covered in the
book was for the first time.

My problem is that many of the example scripts are run on Linux
machines and I am using Win XP Pro. Here is a specific example of what
is confusing me. If I want to open a file from the dos prompt in some
script do I just write the name of the file I want to open (assuming it
is in the same directory) after the script name?
such as

c:\some_script. py some_text_file. txt

Does piping work the same way in dos as it does on a linux machine?
And last but not least, is there a way to do this all from IDLE?

Jul 18 '05 #1
1 1190
Sean wrote:
My problem is that many of the example scripts are run on Linux
machines and I am using Win XP Pro. Here is a specific example of what
is confusing me. If I want to open a file from the dos prompt in some
script do I just write the name of the file I want to open (assuming it
is in the same directory) after the script name?
such as

c:\some_script. py some_text_file. txt
It's unclear to me what you want to do here. If your some_script.py
looks like:

import sys
f = file(sys.argv[1])

then yes, you can call some_script.py as above, and the file will be
readable from the 'f' file object.

Does piping work the same way in dos as it does on a linux machine?
Mostly:

[D:\Steve]$ type test.py
import sys
for i, line in enumerate(sys.s tdin):
sys.stdout.writ e("%i:%s" % (i, line))

[D:\Steve]$ type input.txt
A
B
C
D

[D:\Steve]$ python test.py < input.txt
0:A
1:B
2:C
3:D

[D:\Steve]$ python test.py > output.txt
Z
Y
X
^Z
^Z

[D:\Steve]$ type output.txt
0:Z
1:Y
2:X

[D:\Steve]$ python test.py < input.txt > output.txt

[D:\Steve]$ type output.txt
0:A
1:B
2:C
3:D

[D:\Steve]$ type input.txt | python test.py
0:A
1:B
2:C
3:D
Note however, that you may run into problems if you don't explicitly
call python:

[D:\Steve]$ test.py < input.txt
Traceback (most recent call last):
File "D:\Steve\test. py", line 2, in ?
for i, line in enumerate(sys.s tdin):
IOError: [Errno 9] Bad file descriptor
And last but not least, is there a way to do this all from IDLE?


What exactly do you want to do? You can certainly type something like:

f = file('input.txt ')

in IDLE to get access to the 'input.txt' file...

Steve
Jul 18 '05 #2

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

Similar topics

5
2651
by: mr.iali | last post by:
Hi Everyone I would like to get into software developent using a programming language like c++, java or pl/sql for oracle. I have no idea where to start from. Which language is there more demand for. Looking at jobs there seems to be a better chance in getting a java job rather than a oracle or c++ job. Also is java and oracle a good combiantion?
4
1806
by: Spare Brain | last post by:
Hi, I recently installed SuSE 9.3 on x86, and it seems to contain scripts "apache2" and "mysql" in the /etc/init.d folder. However, these two (Apache or MySQL) are not running when I fresh reboot the machine. I am having to execute a "./apache2 start" and "./mysql start" every time I reboot. I am a newbie when it comes to unix admin, and I am trying to read up about the rc scripts and how they link into the scripts under the...
4
3316
by: techme | last post by:
I am surprised at how little info there is on this topic. We converted to DB2 v8.1.1.72 painlessly a few months ago. For specific reasons, we stayed on 32-bit. Our OS is AIX 5.2 and our hardward is 64-bit P570 LPAR. I need to convert the DB2 DB to 64-bit now. Research suggests that this is a simple 'db2iupdt -w64 command' that will soft link our binaries to the 64-bit cousins. All standard migration steps apply such as take full...
15
4621
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to communicate with a MySQL database table on a web server, from inside of my company's Access-VBA application. I know VBA pretty well but have never before needed to do this HTTP/XML/MySQL type functions.
2
4870
by: Dave Hughes | last post by:
Just noticed something rather annoying after upgrading my test box (a Linux server running DB2 UDB v8 for LUW) to fixpak 11 (for reference it was previously on fixpak 7). In the past I've relied heavily on the ability to start multiple long-running SQL scripts in the background and have them all run in parallel. Unfortunately, it seems that somewhere between fixpak 7 and fixpak 11 something has been fixed / broken which prevents more...
9
1537
by: laststubborn | last post by:
Dear All, We have a big concern in our Database system. We have 2000 transactions daily in our database. We need to replicate some how the database for our fail over setup. I tried transactional replication at midnight but our all systems locked and we had a lot of complaints from the customers and It was taking a lot of time to snapshot part and I had to abort it because of these reasons. I need an advice how I can create a replication...
4
2947
by: tootsuite | last post by:
Help. I have been tasked with upgrading a 2000 instance to 2005. I have actually done this before, but it was a long time ago, and I didn't do it alone. Now, the sitation is little different, and I need to know the EXACT steps to take. Does anyone have a FAQ or link that outlines migration steps? I found one on sql server central, but it isn't very detailed. One of the important things I need to know is, how do I create a
12
3009
by: adamurbas | last post by:
ya so im pretty much a newb to this whole python thing... its pretty cool but i just started today and im already having trouble. i started to use a tutorial that i found somewhere and i followed the instructions and couldnt get the correct results. heres the code stuff... temperature=input("what is the temperature of the spam?") if temperature>50: print "the salad is properly cooked." else:
2
2694
by: jon121970 | last post by:
I'm new here.. I am hoping to get some Professional Advice. I want to start my own online Auction. I anticipate it will grow into a high volume/high traffic online auction. I need some Recommendations as to what platform and what is the best configuration this Auction should be designed in to handle high volume(i.e. Php or ASP or CGI, Mysql)? I've seen some other Auction scripts out there.. but I really don't know the best design for an...
0
9220
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8933
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
7821
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
6567
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
5904
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
4410
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3098
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
2
2396
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2032
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.