- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- test not working
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2004 04:52 AM
03-01-2004 04:52 AM
For some reason my test for non-zero is not working on $newgrp. any ideas?
unset who
who=`/usr/bin/who am i`
if [ -n "$who" ]
then
if [ -n "$newgrp" ]
then
newgrp $newgrp
fi
fi
The error is :
${HOME:-.}/.profile[35]: newgrp: parameter not set
This is why I had the test in, right? It's quoted, so I don't see the problem?
Regs David
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2004 05:00 AM
03-01-2004 05:00 AM
Re: test not working
newgrp=""
first and then try.
#newgrp=""
#if [ -n "$newgrp" ]
>then
>echo yes
>fi
returns nothing
#unset newgrp
#if [ -n "$newgrp" ]
>then
>echo yes
>fi
sh: newgrp: Parameter not set.
newgrp="1"
if [ -n "$newgrp" ]^Jthen^Jecho yes^Jfi
yes
Seems to work.
Regards,
Dave.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2004 05:00 AM
03-01-2004 05:00 AM
Re: test not working
newgrp=
HTH
Marty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2004 05:02 AM
03-01-2004 05:02 AM
Re: test not working
look for set -u
If set, unset variables will result in an error.
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2004 05:02 AM
03-01-2004 05:02 AM
Re: test not working
No typos? strange characters?
First script line is used to spceify shell (#!/bin/ksh or something like that)?
??
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2004 05:07 AM
03-01-2004 05:07 AM
Re: test not working
So first unsetting would not be really apropriate :)
I'dd say that test with a quoted var would always succeed?
Question is still open.
Regs David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2004 05:11 AM
03-01-2004 05:11 AM
Re: test not working
look for set -u
or #!/bin/sh -u
or similar.
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2004 05:12 AM
03-01-2004 05:12 AM
Re: test not working
The $newgrp variable is not set. the "-n" option of test does not test for the existance of a variable, only that it is not empty.
There may be a smarter way but you need something like
if [ $newgrp ] && [ -n $newgrp ]
However, if newgrp is not defined, this will always be false.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2004 05:15 AM
03-01-2004 05:15 AM
Re: test not working
There is no applicable man for set, nor sh that explains the -u flag.
Regs David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2004 05:15 AM
03-01-2004 05:15 AM
SolutionWell. This is because you can find a line "set -u" in your .profile. Irrespective of -n test, 'set -u' going to error out if newgrp is not set. You can override it with
set +u
your_script
set -u
However, you will need to use it at your own risk.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2004 05:18 AM
03-01-2004 05:18 AM
Re: test not working
look man sh-bourne
and search for -u
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2004 05:04 PM
03-01-2004 05:04 PM
Re: test not working
set -u # treats unset variable as error
Als add a
set -xv
to your script. This will show the script commands as they are being executed.
JP.