473,508 Members | 2,130 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is it possible to get whole commandline include redirection.., etc

Can I get whole commandline not only argument list.

1. When I command like this
$ a.py filename
2. sys.argv is returns only argument list
['a.py']

Is there a way to find out 'redirection' information.

thank you for reading this

Jan 12 '07 #1
3 1577
On Friday, Jan 12th 2007 at 15:11 -0800, quoth po*******@gmail.com:

=>Can I get whole commandline not only argument list.
=>
=>1. When I command like this
= $ a.py filename
=>2. sys.argv is returns only argument list
= ['a.py']
=>
=>Is there a way to find out 'redirection' information.

As a new person to python, I'm going to go out on a limb and declare this
to not be a python question and to be a Unix question. If you're running
under Windoze then my answer may not be valid since, as you can see, I
only recently learned how to spell it.

When any Unix commandline is handed to a shell, all pipes and redirections
are processed by that shell so that the various IO channels for the
command are defined to point to the desired files before the command is
even started. Only after that setup has occured is the desired command
even started. There are books on the subject and this is not the correct
forum to explain it all, but the docs to read that will leave you with no
hint of idiomatic usage are all in section 2: fork, exec, open, close, dup
and pipe (plus a few others not germain here also).

--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
Jan 12 '07 #2
Thanks Steven.

Jan 14 '07 #3
po*******@gmail.com wrote:
Can I get whole commandline not only argument list.

1. When I command like this
$ a.py filename
2. sys.argv is returns only argument list
['a.py']

Is there a way to find out 'redirection' information.
It's not possible to find the exact command line redirections.

However, you can tell whether a standard I/O stream has been redirected
or not (kind of) using isattr attribute. For instance,
sys.stdin.isatty() returns 1 when it's not being redirected. It's not
exact, though. It's possible to redirect to a device that is a tty,
and sometimes standard I/O streams will not be ttys even without
redirection, such as when run by a script with redirection. (It
shouldn't be a problem, since the main use case is to check whether the
program should run in interactive mode or not.)
Carl Banks

Jan 14 '07 #4

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

Similar topics

3
2213
by: Hans Dembinski | last post by:
Hi there, I run in a problem with a script, that shall work similar like the c-program "most". It should be able to get some text on execution via a pipe but also is interactive by the user via...
5
4376
by: mark | last post by:
Hi, Newbie here. Here's my code for a c# console app: public static int Main(string args) { if (args.Length == 0) { Console.WriteLine("Please enter a database name."); return 1;
1
1599
by: Rvo | last post by:
I'm writing an application that should work both as a GUI and a commandline program. When running from commandline I want to give all output to the commandline instead of showing it it an own...
2
7053
by: Christoph Borger | last post by:
Hello! I have wrote a windows service in vb.net. This service monitors the running processes with WMI and the Win32_Process class. Till last month all seems ok. But since the begin of september...
3
1846
by: pemo | last post by:
Opinion please. The code below is an attempt at demonstrating commandline arg processing. I don't really like the repetitive use of ... if(!(*s)) { // Make sure we don't go out of bounds....
0
2707
by: axlq | last post by:
While trying to learn the ins and outs of the php CURL library, I decided to write a php script that posts a form on the Chicago Board of Options (CBOE) web site, which returns an ASCII text file. ...
1
1490
by: RSH | last post by:
Hi, I have a silly question... I have a Windows Form project (VB.Net) that was created in Visual Studio 2003. The project runs great. Now I have to add the ability to run the same...
2
1684
by: andreas.huesgen | last post by:
Hello, I am writing a commandline tool in Python which is often feed with lots of commandline arguments. In practice, the commandline already reached a critical length which is to long for Windows...
7
1692
by: Computer Guru | last post by:
Hello All, I'm at my wit's end on this one, and would appreciate any help or insight that could be given. Environment: Windows Vista x64 ONLY Code: //START BUG
0
7225
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
7123
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
7383
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
7046
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
7498
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...
0
5627
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,...
0
3194
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...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1557
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 ...

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.