473,578 Members | 3,025 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 1585
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.isatt y() 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
2218
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 the curses module (for scrolling and stuff). The problem is: if you call the script like that, you connect stdin to text.txt and any later keyboard...
5
4381
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
1607
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 interface. When I use Console.writeline the output doesn't appear at the commandline prompt though. I guess this is because the default output for the...
2
7074
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 the service can't retrieve the commandline property of the processes. I think this is an result of .NET Framework 1.1 Service Pack 1 or XP SP2. Did...
3
1852
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
2724
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. CBOE appears to keep your form query data in cookies, so this seemed like a good use of curl. Well, my script works just fine when run from the...
1
1499
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 application from a commandline. The obvious issue is going to be with all of the form specific settings...luckily I wrote the app using classes to seperate...
2
1690
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 (some versions of Windows only support commandlines of up to 2047 characters). To work around this problem, wethought up the idea of bypassing the...
7
1695
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
7778
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
8125
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. ...
0
8290
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7874
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
8148
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
6522
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
5664
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
3781
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
1389
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.