can't get the variable to set
doesn't seem to set or know about ADG_svrname env.
|
Works for me
Code:
$ cat test Code:
$ ./test Where are you going with the rest of that if statement? There's no close in your example code. |
Hi,
if I add a "fi" to the end of your script it works fine for me. My ksh is: Code:
% /bin/ksh --version Evo2. |
I am bit confusing of when you use ksh, sh or plain? which is which, could you please explain?
|
thx
|
Hi,
it depends on your needs. For high portability and speed, straight bourne shell (sh) is probably best. For "features" bash is a good option. IMHO, on a GNU/Linux system ksh is probably not such a good choice these days: bash has a similar feature set and is much more likely to be installed. There is quite a bit on the web on this topic, and know that others here at LQ have opinions on this. Cheers, Evo2. PS. I use zsh for my login shell, and a either bash or sh for scripting. |
Using "sh" means you're executing the script in posix-compatibility mode. It may still be ksh, but restricted in features, or it may be a different shell entirely. You'll almost always want to use the full #!/bin/ksh shebang unless you really need portability.
Also, dirname, and the command substitution that goes with it, is unnecessary, since every major shell has at least basic parameter substitutions built in. $(..) is highly recommended over `..` too. QUOTE ALL OF YOUR VARIABLE SUBSTITUTIONS. You should never leave the quotes off a parameter expansion unless you explicitly want the resulting string to be word-split by the shell (globbing patterns are also expanded). This is a vitally important concept in scripting, so train yourself to do it correctly now. You can learn about the exceptions later. http://mywiki.wooledge.org/Arguments http://mywiki.wooledge.org/WordSplitting http://mywiki.wooledge.org/Quotes And learn how to format effectively too. At the very least indent your subsections. Scripting With Style Code:
#!/bin/ksh Quote:
Again, read is usually the command to use. Assuming there's only a single line: Code:
read -r variable <filename How can I read a file (data stream, variable) line-by-line (and/or field-by-field)? http://mywiki.wooledge.org/BashFAQ/001 |
thx
|
Then you just need to "source" that file, in order to execute every command/variable definition inside there:
Code:
. $Sdir/ADG_svrname.var Code:
source $Sdir/ADG_svrname.var |
Excuse me, why did you delete your opening post? (And most of the following ones too?) You've now made it harder for readers to follow the rest of the thread. That's considered rather impolite, to say the least. Please don't do it again.
There's nothing to be embarrassed about, if that's your reason. Everybody is new sometime, and we all make mistakes. All criticisms given were only to help you with your problem and to improve your skill. |
Moderator note: @brian00: I don't see any reason for deleting your question and subsequent feedback, especially after having received useful answers from other LQ members. This is not respectful towards people that voluntarily spent some of their time to help you! Please, refrain from doing that in the future. Thread closed.
|
I am sorry, won't do it again
|
All times are GMT -5. The time now is 12:28 AM. |