|
Hi John,
I am drawing a blank here.
How do I test for the absence of of a parameter in a shell script?
I'm assuming you by "shell script" you mean either QShell or Bourne
shell. If that's wrong, please tell me so.
It depends on what you mean by "absence". Consider the following
command-line that runs a script of mine:
runxfer.sh -u klemscot -p bigboy sftp.klements.com
If I changed it to look as follows, what would be "absent"?
runxfer.sh -u klemscot sftp.klements.com
Would I say that the 3rd and 4th parameters weren't passed? Because,
technically, the 3rd parameter WAS passed... it just isn't -p anymore.
So it's really a hard question to answer. It really depends on the
paradigm in which you wrote your script.
how about if I did this:
runxfer.sh -u klemscot -p "" sftp.klements.com
Now I have the same number of parameters as my original example, but one
of them is an empty string. Does that count as being passed or not?
So, really, the first thing you need to decide... how are you handlign
parameters? Are you using option flags with values? Or is it purely
positional?
Then you need to decide what is considered "absence"? If a string is
passed, but is blank, is that considered absent?
Sorry. I hate complicating things -- but I want to make sure I'm
answering the right question.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.