Tooltip: Parsing (getopts) for -u successfully sets mode=umnt, but case umnt is not executed,
instead it either executes/show help or regular mount screen.
The script is ment to create a credentials file for mounting a nas, and an additional file for each share.
The creation of the config files and mounting work as it should.
However, when i want to unmount the share, it either shows the help screen (happens with none or wrong arguments) or the mount screen again.
The issue is, it doesnt seem to execute umount eventhough i passed -u and it did recognize it.
However, other arguments are executed properly...
Some output of a set -x run while passing -u (italic in code section: Variable handling):
And here is the code, followed by 1 successfull mount, and 2 umount tries:
Any idea why its showing the helpscreen eventhough the $mode was set to unmount (umnt)?
Thank you in advance
---------- Post updated at 16:23 ---------- Previous update was at 15:23 ----------
Its working, but not really sure why...
I removed all the OPTIND stuff, i thought that should remove the "-u" from the arglist, but neither OPTIND itself, nor OPTIND -1 helped on that matter (or i did wrong):
and
Have a nice day
/solved
The OPTIND you removed is crucial to allow getopts() to work correctly.
But, I'm having trouble matching the arguments you're passing to getopts (edhmou: and name) with your USAGE description of your options:
The colon following the u in the option string argument to getopts (edhmou:) says that the -u option takes an option-argument (and the lack of a colon following the other option letters in that string says that no other options take option-arguments), but there is nothing in you code parsing the -u option:
that gathers up the option-argument that getopts will identify for you.
So, do the -d, -e, -o, and -u options (all described as performing an operation on a "provided nas/share/s") get the provided nas/share/s as an option-argument or is the nas/share/s always an operand?
Store args passed in array but not the first 2 args.
# bash
declare -a arr=("$@")
s=$(IFS=, eval 'echo "${arr}"')
echo "$s"
output:
sh array.sh 1 2 3 4 5 6
1,2,3,4,5,6
Desired output:
sh array.sh 1 2 3 4 5 6
3,4,5,6 (2 Replies)
Hello,
I have a similar problem so I continue this thread.
I have:
my_script_to_format_nicely_bdf.sh | grep "RawData" |tr -s ' '|cut -d' ' -f 4|tr -d '%'
So it supposed to return the percentage used of RawData FS:
80
(Want to use it in a alert script)
However I also have a RawData2 FS so... (17 Replies)
Hi I am executing a KSH script by passing command line arguments
example: Red Green Dark Red Blue
when I am splitting the arguments by using " "(Space) as delimiter
But the colour Dark Red is a single parameter. But it is getting splitted in between
How to avoid this. Please help Also... (4 Replies)
Hi all,
I am having problems parsing the following file:
cat mylist
one,two,three
four
five,six
My goal is to get each number on a seperate line.
one
two
three
four
five
six
I tried this command:
sed -e 's/\,/^M/g' mylist (11 Replies)
I need help with a problem that I have not been able to figure out.
I have a file that is about 650K lines. Records are seperated by
blank lines, fields seperated by new lines. I was trying to make
a report that would add up 2 fields and associate them with a CP.
example output would be... (11 Replies)
I'm trying to parse the variables out of a comma delimited expression, but i'm having trouble with script:
num_var=1
while
do
a=`echo "a=7, b=8, c=9" | awk '{print $num_var}' | cut -d= -f2`
b=`echo $a | cut -d, -f1`
echo $b
num_var=`expr $num_var + 1`... (5 Replies)