473,461 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem with Getopt

Hi Guys,
I am summarizing this problem with a example. Appreciate if someone
could help me.

Say, I have a wrapper shell script which calls a perl program. I want
to pass the command line options to this perl program.

In the Wrapper (TCSH) script, I have something like this
set TEMP = "x y z";
mytest.pl -t ${TEMP};
------------------------
In the Perl program, I have something like this;
(Only fragment shown)
my $status = GetOpt::Long:GetOptions ('t|test=s' => \$temp_var);
print "$temp_var \n";
---------------
This prints only x and not all of the "x y z"
I am new to Perl but reasonably good in scripting.. Please help me..

Regards,
Arvind Kumar
Jul 19 '05 #1
1 2898
In article <ff**************************@posting.google.com >, Arvind
Kumar <ok******@yahoo.com> wrote:
Hi Guys,
I am summarizing this problem with a example. Appreciate if someone
could help me.

Say, I have a wrapper shell script which calls a perl program. I want
to pass the command line options to this perl program.

In the Wrapper (TCSH) script, I have something like this
set TEMP = "x y z";
mytest.pl -t ${TEMP};
This is equivalent to the command line: 'mytest.pl -t x y z'
Thus, 'x' is the value of the -t parameter. 'y' and 'z' are ignored by
the '-t' option according to the normal syntax of command line options.
------------------------
In the Perl program, I have something like this;
(Only fragment shown)
my $status = GetOpt::Long:GetOptions ('t|test=s' => \$temp_var);
It's spelled 'Getopt' on my system!
print "$temp_var \n";
---------------
This prints only x and not all of the "x y z"
I am new to Perl but reasonably good in scripting.. Please help me..

Regards,
Arvind Kumar


Your program is behaving normally. If you want to enter 'y' and 'z' as
some type of command line option, you must tell Getopt about the
additional options. If you really want to enter "x y z" as the
parameter for the -t option, put it in quotes: mytest.pl -t "x y z"
In your shell script, you need to do:

mytest.pl -t "${TEMP}"
Jul 19 '05 #2

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

Similar topics

6
by: David Bear | last post by:
I'm stumped. Trying to follow the docs and .. failure. here's the args >>> args '-Middwb@mainex1.asu.edu -AKHAAM@prlinux+898 -CA --D2003-08-20-09:28:13.417 -Ff -Hprlinux...
4
by: Dan Rawson | last post by:
Is there any way to force getopt to process one option first?? I'd like to be able to pass in the name of a configuration file for my application, then have the remaining command-line parameters...
0
by: Bruce Davis | last post by:
I'm having a problem on windows (both 2000 and XP) with a multi-threaded tkinter gui application. The problem appears to be a deadlock condition when a child thread pops up a Pmw dialog window in...
3
by: Dominik Kaspar | last post by:
I tried to use getopt and copied the example from: http://www.python.org/doc/current/lib/module-getopt.html but nothing is working... getopt.GetoptError doesn't seem to exist and when i run the...
3
by: Don Low | last post by:
Hi, I'm going over a script that demonstrates the getopt function. I include the script here: #! /usr/bin/python import sys, getopt, string
6
by: Frans Englich | last post by:
Hello, In my use of getopt.getopt, I would like to make a certain parameter mandatory. I know how to specify such that a parameter must have a value if it's specified, but I also want to make...
1
by: Andrew | last post by:
Dear Experts, I have a perl program that using Getopt:Std module, when I try to run the GetOpt program, the following error returned: Can’t locate Getopt.pm in @INC (@INC contains:...
4
by: pinkfloydhomer | last post by:
I want to be able to do something like: myscript.py * -o outputfile and then have the shell expand the * as usual, perhaps to hundreds of filenames. But as far as I can see, getopt can only...
14
by: Markus Mayer | last post by:
Hi. Any chances that there is a similar thing to *nix's getopt() under windows? (It doesn't actually have to be too nifty, the requirement is just that it is stable.) Regards, Markus
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:
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
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,...
0
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...
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...
0
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
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...
0
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.