I am re-writing a script I wrote which emulated the "rm" command, in my orginal script I had problems with precedence, I did find a way round it by creating a seperate case statements which checked the options and performed the actions accordingly, does anyone know if I can use getopts better to help with precedence? and save on using the extra case statement.
So instead of this part of my code:
I can manage it within getopts by just using this:
I have ommitted the rest of my code but I am trying to emulate the "rm" and I am providing other functions to move the files to a trash folder rather than delete for good.
So, given this option argument: -fi it should not force but should interact but if I enter -if it should not interact but should force, how do I utilise getopts to allow for this withour the case statement in the top code?
Hi. Can somebody please show me an example of how to use getopts to assign a variable if it's been passed into the script but to set a default if no value has been passed in? And also how to handle a param with multiple values ... so a sub parse (can I use a function for this?)?
Here's my code... (1 Reply)
while getopts v OPTION
do
case $OPTION in
v) echo "Hello" ;;
*) exit 1;;
esac
done
Suppose I have script tmp.sh
Whose Signature is tmp.sh <fixed_argument>
When I run the script with tmp.sh -v "file", it echoes a hello but, when I try the other way i.e, tmp.sh... (1 Reply)
Trying to figure out the best method of security for oracle user accounts. In Solaris 10 they are set as regular users but have nologin set forcing the dev's to login as themselves and then su to the oracle users.
In Solaris11 we have the option of making it a role because RBAC is enabled but... (1 Reply)
Hi All,
I am new to unix.
In this forum some days back, I have read something like below:
1) Do not use perl if awk can do your work.
2) Do not use awk if sed can do your work.
.
.
.
I do not re-collect the whole thing. I think it is good to know the precedence of using these... (2 Replies)
Hello,
I am trying to write a small acript to change directory to $HOME depending on the user logged in. However when i provide this command
say,
ABC_USER=myself
cd ~${ABC_USER} i am getting the following error,
ksh: ~myself: not found
I know i am doing something really silly but... (4 Replies)
Hi All,
I have created a common makefile that compiles both pc and c files.
i have created the dependency between the files as
.pc.o:
-----------
.c.o:
-----------
I will be deleting the .c files created from the .pc files, once the object file is created. ( better storage... (7 Replies)
Hi,
My script will take a input file as a parameter(which is not mandatory) and also an option.
ksh my_script.sh <inputfile>
The option -n I have given is no way related to the input file.
Now the problem here is when i execute the script specifying the input file and the option(the way... (4 Replies)
#!/usr/bin/perl
open(STDOUT, ">>$Textfile")
open(STDERR, ">>$Textfile")
print "program running\n";
$final = join("+", $initial,$final) #5
close (STDOUT);
close (STDERR);Hi all, above is my perl code. Notice i have captured the stdout and stderr to the same textfile. my code is expected to... (1 Reply)
I have a script which fires a command based on certain parameters. I am posting the code below..
The options needs be given such that
-u option goes along with -d and -s, -f goes with -d and -t goes with -s and -d.
1) How do I ensure that user misses any of the option then he should be... (5 Replies)
Gurus,
I am teaching myself C and have a question.
I wrote a small prog that reads characters as entered at the prompt and checks the value for EOF.
Unless I am 100% wrong, the value will be '1' until getchar() has anything to read in my stream.
/* PROG 1 */
#include <stdio.h>
... (4 Replies)