473,785 Members | 2,669 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Angle brackets in command-line arguments?

Hi all,

I am using someone else's script which expects input in the form of:

./script.py <arg1arg2

I was wondering if the angle-brackets here have a special meaning? It
seems like
they specify an input and output stream to use in place of the
console. I could not
find anything in the python manual or Python in a Nut-shell though.

Anyone know?
Thanks,
Keith
Jul 16 '08 #1
4 7452
On Wed, 16 Jul 2008 07:53:56 -0700, Keith Hughitt wrote:
I am using someone else's script which expects input in the form of:

./script.py <arg1arg2

I was wondering if the angle-brackets here have a special meaning? It
seems like they specify an input and output stream to use in place of the
console. I could not find anything in the python manual or Python in a
Nut-shell though.

Anyone know?
That's not Python's business but the command shell's. Those characters
are used for redirecting input and ouput from/to files in shells, so it
should be covered in the documentation of the shell you are using.
Including ways to protect the characters, so they reach the called program
in arguments.

Ciao,
Marc 'BlackJack' Rintsch
Jul 16 '08 #2
Keith Hughitt wrote:
I am using someone else's script which expects input in the form of:

./script.py <arg1arg2
<argis a common notation for "replace with argument value", so it
could be that they're just expecting you to type:

./script.py arg1 arg2

Alternatively, they meant

./script.py <arg1 >arg2

in which case arg1 and arg2 are filenames. This is most commonly used
with tools that process textfiles in some way. In the latter case, you
can try the script simply by running:

./script.py

and then typing the input to the terminal (use control-D on Unix or
control-Z on Windows to terminate).

Do the instructions use more meaningful names than "arg1" and "arg2"?

</F>

Jul 16 '08 #3
Keith Hughitt wrote:
Hi all,

I am using someone else's script which expects input in the form of:

./script.py <arg1arg2

I was wondering if the angle-brackets here have a special meaning? It
seems like
they specify an input and output stream to use in place of the
console. I could not
find anything in the python manual or Python in a Nut-shell though.

Anyone know?
Thanks,
Keith
--
http://mail.python.org/mailman/listinfo/python-list

In most Unix/Linux and related OS shells, the angled brackets *do*
specify input and output streams as you surmise. However, they are
*not* seen by the script as command line arguments. (And they are
*not* brackets, and do not need to be matched. )

For any command,
cmd < file
redirects the contents of file to cmd's standard input, which in Python
is accessed by reading from sys.stdin (use input or raw_input or
sys.stdin.read. ..)

Also for any command,
cmd file
redirects the output of cmd to the named file. In Python this can be
accessed using print, sys.stdout.writ e, ...

Anything written to sys.stderr will not be caught by the ">"
redirection, ans so will probably end up on the screen instead of in file.

Also various shells will provide similar functionality using a variety
of similar syntaxes: <<, >>, >&, and |, and so on.

Gary Herron
Jul 16 '08 #4
On Jul 16, 11:16*am, Gary Herron <gher...@island training.comwro te:
Keith Hughitt wrote:
Hi all,
I am using someone else's script which expects input in the form of:
* * *./script.py <arg1arg2
I was wondering if the angle-brackets here have a special meaning? It
seems like
they specify an input and output stream to use in place of the
console. I could not
find anything in the python manual or Python in a Nut-shell though.
Anyone know?
Thanks,
Keith
--
http://mail.python.org/mailman/listinfo/python-list

In most Unix/Linux and related OS shells, *the angled brackets *do*
specify input and output streams as you surmise. *However, they are
*not* seen by the script *as command line arguments. *(And they are
*not* brackets, and do not need to be matched. )

For any command,
* cmd < file
redirects the contents of file to cmd's standard input, which in Python
is accessed by reading from sys.stdin (use input or raw_input or
sys.stdin.read. ..)

Also for any command,
* cmd file
redirects the output of cmd to the named file. *In Python this can be
accessed using print, sys.stdout.writ e, ...

Anything written to sys.stderr will not be caught by the ">"
redirection, ans so will probably end up on the screen instead of in file..

*Also various shells will provide similar functionality using a variety
of similar syntaxes: *<<, >>, >&, and |, and so on.

Gary Herron
Thanks all for the quick response. I should have known it was shell-
related. I haven't ever had to use this
kind of redirection before, mostly just the single-bracket version to
feed the contents of a file into some
command.

The reason it was causing me concern in the first place was that I was
trying to execute a python script
from Apache Ant, and it was failing. It turned out that when I escaped
the angle brackets in Ant, they were
there-after treated as normal command-line arguments, so when the
script was then executed, it just had
some additional values in sys.argv.

I ended up getting around the issue by creating a small bash-script
which simply wraps input in angle brackets
and then executes the python script itself. That way I didn't have to
escape anything in in Ant, and things
worked well.

Thanks everyone for taking the time to explain things to me. I really
appreciate the help :)

Take care,
Keith
Jul 16 '08 #5

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

Similar topics

5
3131
by: Darren Grant | last post by:
Hi there, I've attempted to implement an Angle class. An Angle is a subset of an integer, where the range is [0,360). All other operations should be permitted. The code works, I think... except (for example) a = b + 10; needs to be a = b + (Angle) 10; Could some kind soul comment on my code and show me how it could be
1
2046
by: Greg | last post by:
I have an Access db (actually, about 60 of them) that has a table with a field named Q#. This table gets read into a dataset. In the dataset, the field is also called Q#. But when I try to update the db, an error occurs because Access wants the field to be surrounded by brackets - - when written back. I know this is the problem, because if I change the fieldname to QNum, it works fine. Using the commandbuilder, or building the INSERT,...
2
4508
by: DotNetGruven | last post by:
We have a web service that returns a string which happens to be well formed XML. The client sees the string ok, except the angle brackets are HTML encoded ( &gt and &lt ). Is this expected behavior? Is there a way to configure it so that it doesn't do this? Currently, the client is being required to use HTML.decode() to fix it, but they would rather not?
15
46485
by: cwsullivan | last post by:
Hi gang, I have a grid full of particles in my program, and I want to find an angle between two particles. I'm having trouble because it seems like the answer depends on whether or not the target particle is above or below, in front or behind the refernce particle. If I have a reference particle at (10,10), and another particle at (20,20), i'm currently finding the angle by: angle = atan((10-20)/(10-20)) = 45 degrees. When I draw this...
2
2176
by: Kenneth Porter | last post by:
If you email your users links and wrap the links in angle brackets, beware users using Yahoo Mail. It includes the trailing angle bracket in the link, preventing it from working. (This was happening with my site's "forgotten password" system, so people couldn't reset their passwords.) As a workaround, you can have your code check for a trailing ">" and strip it before further processing. I submitted a bug report using Yahoo's generic bug...
3
2885
by: Doraj | last post by:
Hello ! Here is my problem : I had some php scripts which worked well with php 4.0.5 (GD 1.6.2 according to phpinfo() ) and i put them on a new server with php 4.4.2 (and GD 2.0.28). Now, they don't do what they should : i'm generating an image with text written with an angle : imagettftext used
2
4302
by: Peter | last post by:
Hi, I was wondering, can anyone tell me what statements in angle brackets are for in VB? For example, the default <System.Diagnostics.DebuggerStepThrough()thing that the IDE puts before the InitializeComponent method of a form.
4
3967
by: Nunzio | last post by:
I am trying to build an email address in PHP code using v5.1.2. All works well until I try to surround the email address with angle brackets. Every method I try causes the email address to disappear completely. I have to believe that this is a common problem, but I can't find any answers in the PHP docs or in Google. Any insight would be greatly appreciated. Below are some of my failed attempts. $strAddressee = "$ContactName...
2
2554
by: laredotornado | last post by:
Hi, I'm using php 4.4.4. Maybe I'm misreading the docs, but in the imagettfbbox manual (http://us2.php.net/imagettfbbox), it says that text coordinates are the same regardless of what the angle is. But I am getting two distinct sets of coordinates if I change the angle from zero to 270. Here's the relevant code:
6
2730
by: jeffg | last post by:
I have created a site that uses a Doctype of XHTML Transitional and a character set of utf-8, in case any of this matters. I have validated every page and cleaned up all errors. IE displays the pages fine but Firefox 3 puts a stray left angle bracket at the lower left corner of every page. I have used my dev tool to search my code for extra brackets and found nothing I have run out of options for what to analyze. Any suggestions of what...
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10324
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
10147
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9949
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
8971
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...
0
6739
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
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2879
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.