473,395 Members | 1,539 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How do you get sys.stdin filename?

This is probably scripting more than python? I don't know either, so what the hey. I can't get the name of the file that I pass as argument to a python script, say

python myscript.py < "input.param"


From the script if I do

Expand|Select|Wrap|Line Numbers
  1. print "Name=",sys.stdin.name
I get

Expand|Select|Wrap|Line Numbers
  1. Name= <stdin>

I was expecting sys.stdin.name to give me "input.param" instead. How do I get the file name? I'm basically trying to figure out if a file was passed as argument or not, and I want the file name to check if that file exists. If it wasn't passed and I try to read it, it waits for interactive input and I don't want that.

Any ideas?
Apr 26 '07 #1
1 4520
Uhem. Please ignore me, I got it. Not enough coffee or something.
Apr 26 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Charlie Zender | last post by:
Hi, I have a program which takes the output filename argument from stdin. Once the program knows the output filename, it tries to open it. If the output file exists, the program asks the user to...
11
by: David Warner | last post by:
Greetings! I need to write some C code that will decide between either reading from stdin or take a file name from argv and process it. The program needs to work like all of the typical unix...
7
by: Will McDonald | last post by:
Hi all. I'm writing a little script that operates on either stdin or a file specified on the command line when run. I'm trying to handle the situation where the script's run without any input...
5
by: the.theorist | last post by:
I was writing a small script the other day with the following CLI prog * I've used getopt to parse out the possible options, so we'll ignore that part, and assume for the rest of the discussion...
4
by: ACB | last post by:
I am rewriting an existing PERL script I wrote several months ago. It is a script that is used as the action for a form containing several type="file" inputs. The script is run unbuffered and...
25
by: 7stud | last post by:
I can't break out of the for loop in this example: ------ import sys lst = for line in sys.stdin: lst.append(line) break
3
by: Tartifola | last post by:
Hi, suppose a script of python is waiting for a file from the stdin and none is given. How can I make the script to stop and, for example, print an error message? Sorry for the n00b question...
31
by: Nikos Chantziaras | last post by:
Hello. Is there a way to check if the current process has an stdin handle? In the win32 API, one can do: _eof(_fileno(stdin)) Crucial here is that the above doesn't block. Is there a...
6
by: Michael Goerz | last post by:
Hi, I would like to raise an exception any time a subprocess tries to read from STDIN: latexprocess = subprocess.Popen( \ 'pdflatex' + " " \ + 'test' + " 2>&1", \ shell=True, \...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...
0
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...

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.