Sponsored Content
Full Discussion: Adding an Option
Top Forums Shell Programming and Scripting Adding an Option Post 302140915 by Brusimm on Tuesday 16th of October 2007 04:29:45 PM
Old 10-16-2007
Adding an Option

I have a file that takes 2 or 3 arguments...
ie: $argv(2), $argv(3)

If I had to add another argument, I would be ok, but nooo.. that would be too easy for the new programmer. Before you go there - This is not a school problem, it's a real world problem..

If I wanted to add an option, for example,
run the script with a -c <filename> as an option, can I mix this option with the arguments structure?

Also, would this be a getopt(s) kind of option I have to add to the script?

Thanks for your time.

Bruce
 

10 More Discussions You Might Find Interesting

1. Programming

cc option

my yacc output file y.tab.c is not compiling using cc y.tab.c -ly command .possibily option flag -ly is not correct.i m using red hat linux 9.please give solutions. (4 Replies)
Discussion started by: kuldeep_bora
4 Replies

2. Shell Programming and Scripting

option followed by : taking next option if argument missing with getopts

Hi all, I am parsing command line options using getopts. The problem is that mandatory argument options following ":" is taking next option as argument if it is not followed by any argument. Below is the script: while getopts :hd:t:s:l:p:f: opt do case "$opt" in -h|-\?)... (2 Replies)
Discussion started by: gurukottur
2 Replies

3. Programming

probs adding linker option in g++

Hi all Im trying to compile a C++ program, however Im having issues trying to link a particular library to the compiling and linking statement. Here is what Im doing g++ mips4 -std=c++98 -g disk_reporter.cpp -o disk_reporter If I do this alone, the linker complains that library... (2 Replies)
Discussion started by: JamesGoh
2 Replies

4. Shell Programming and Scripting

Can there be a better option?

Hello, I am still in the process of learning Shell Programming. The online manual, that I am referring to had following question: I made a script as follows: df --block-size=1GB | tr -s ' '| cut -d' ' -f2,5 | grep -v 1GB* | sort -k1,2n | tail -1 | cut -d' ' -f2 | cut -d '%' -f1 and it... (2 Replies)
Discussion started by: shahdharmit
2 Replies

5. Shell Programming and Scripting

Adding new lines to a file + adding suffix to a pattern

I need some help with adding lines to file and substitute a pattern. Ok I have a file: #cat names.txt name: John Doe stationed: 1 name: Michael Sweets stationed: 41 . . . And would like to change it to: name: John Doe employed permanently stationed: 1-office (7 Replies)
Discussion started by: hemo21
7 Replies

6. Shell Programming and Scripting

recently introduced to the newer option for find...does an older option exist?

To find all the files in your home directory that have been edited in some way since the last tar file, use this command: find . -newer backup.tar.gz Is anyone familiar with an older solution? looking to identify files older then 15mins across several directories. thanks, manny (2 Replies)
Discussion started by: mr_manny
2 Replies

7. Shell Programming and Scripting

[Solved] adding email option to KSH

Hi, I wanted to add a email option to this script. and was wondering if anyone could help me out. #!/bin/ksh echo "Finding hdisk" <DIR>/find-disk i=1 b=0 p=0 while ... (2 Replies)
Discussion started by: vpundit
2 Replies

8. Shell Programming and Scripting

Adding another option to getopt

I am trying to code for the addition of a new argument to the command line, the option D to a code that already has ABC (below). When I use make to compile it, it displays: invalid option --D. I did define the global d variable, as well as initialized it inside the main function of the C code. I... (9 Replies)
Discussion started by: Alabama
9 Replies

9. Solaris

Unrecognized option: sparc-sun-Solaris2.10/bin/as: unrecognized option `-m32'

Hi, I installed some packages required by an app built with python. But when I try python setup.py install, I get the following error: /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.2.0/../../../../sparc-sun-solaris2.10/bin/as: unrecognized option `-m32' Could anyone tell me what's wrong... (4 Replies)
Discussion started by: Kimkun
4 Replies

10. UNIX for Beginners Questions & Answers

Adding to an array in an external file, and adding elements to it.

I have an array in an external file, "array.txt", which contains: char *testarray={"Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"};I want to be able to add an element to this array, and have that element display, whenever I call it, without having to recompile... (29 Replies)
Discussion started by: ignatius
29 Replies
execl(3)						     Library Functions Manual							  execl(3)

Name
       execl, execv, execle, execlp, execvp, exect, environ - execute a file

Syntax
       execl(name, arg0, arg1, ..., argn, (char *)0)
       char *name, *arg0, *arg1, ..., *argn;

       execv(name, argv)
       char *name, *argv[];

       execle(name, arg0, arg1, ..., argn, (char *)0, envp)
       char *name, *arg0, *arg1, ..., *argn, *envp[];

       execlp(file, arg0, arg1, ..., argn, (char *)0)
       char *file, *arg0, *arg1, ..., *argn;

       execvp(file,argv)
       char *file, *argv[];

       exect(name, argv, envp)
       char *name, *argv[], *envp[];

       extern char **environ;

Description
       These  routines provide various interfaces to the system call.  Refer to for a description of their properties; only brief descriptions are
       provided here.

       In all their forms, these calls overlay the calling process with the named file, then transfer to the entry point of the core image of  the
       file.  There can be no return from a successful exec.  The calling core image is lost.

       The  name  argument is a pointer to the name of the file to be executed.  The pointers arg[0], arg[1] ...  address null-terminated strings.
       Conventionally arg[0] is the name of the file.

       Two interfaces are available.  is useful when a known file with known arguments is being called; the arguments to are the character strings
       constituting the file and the arguments; the first argument is conventionally the same as the file name (or its last component).  A 0 argu-
       ment must end the argument list.

       The version is useful when the number of arguments is unknown in advance.  The arguments to are the name of the file to be executed  and  a
       vector of strings containing the arguments.  The last argument string must be followed by a 0 pointer.

       The  version  is used when the executed file is to be manipulated with The program is forced to single step a single instruction giving the
       parent an opportunity to manipulate its state.  On VAX-11 machines, this is done by setting the trace bit in the process status longword.

       When a C program is executed, it is called as follows:
	    main(argc, argv, envp)
	    int argc;
	    char **argv, **envp;
       where argc is the argument count and argv is an array of character pointers to the arguments themselves.  As indicated, argc is convention-
       ally at least one and the first member of the array points to a string containing the name of the file.

       The argv is directly usable in another because argv[argc] is 0.

       The envp is a pointer to an array of strings that constitute the environment of the process.  Each string consists of a name, an "=", and a
       null-terminated value.  The array of pointers is terminated by a null pointer.  The shell passes an environment entry for each global shell
       variable  defined  when	the program is called.	See for some conventionally used names.  The C run-time start-off routine places a copy of
       envp in the global cell which is used by and to pass the environment to any subprograms executed by the current program.

       The and routines are called with the same arguments as and but duplicate the shell's actions in searching for an executable file in a  list
       of directories.	The directory list is obtained from the environment.

Restrictions
       If  is  called  to  execute  a  file that turns out to be a shell command file, and if it is impossible to execute the shell, the values of
       argv[0] and argv[-1] will be modified before return.

Diagnostics
       If the file cannot be found, if it is not executable, if it does not start with a valid magic number if maximum memory is exceeded,  or	if
       the  arguments  require too much space, a return constitutes the diagnostic; the return value is -1.  For further information, see Even for
       the super-user, at least one of the execute-permission bits must be set for a file to be executed.

Files
       /bin/sh	 Shell, invoked if command file found by execlp or execvp

See Also
       csh(1), execve(2), fork(2), environ(7)

								       RISC								  execl(3)
All times are GMT -4. The time now is 02:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy