- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- test oddity
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
02-05-2002 07:12 AM
02-05-2002 07:12 AM
A few days I wrote a script to kill off old hung processes on a system. One of the checks I do is to run a ps -ef and grab the 6th field. If it's a question mark then the process is ok (as that means the time stamp is still the time), if it's anything else then it's an old process and should be killed (as the time stamp has converted to month/day and therefore created a new field).
Anyway it works fine, except that I noticed that processes that had a date of the 7th weren't being killed. After looking into this a bit I found that when I compare [ $x != ? ] (with the value of $x being 7) it considers them to be equal. Below is a short test script that shows the issue. Anyone know why this is?
a=1
while [ $a -lt 10 ]
do
if [ $a != ? ]
then
echo "not equal"
else
echo "equal"
fi
a=`expr $a + 1`
done
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2002 07:24 AM
02-05-2002 07:24 AM
Solutionif [ $a != \? ]
so that the script interpreter does not use the ? as a special character. Running your example script in ksh with the -x option to debug, you can see it makes 1=1.
mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2002 07:29 AM
02-05-2002 07:29 AM
Re: test oddity
Anyway, thanks again :)
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2002 07:31 AM
02-05-2002 07:31 AM
Re: test oddity
Do you have a file named 7 in the directory where you run the script? That would cause the problem.
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2002 07:40 AM
02-05-2002 07:40 AM
Re: test oddity
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2002 12:20 PM
02-05-2002 12:20 PM
Re: test oddity
The shell turns ? (unless escaped or quoted) into the list of files in the current directory named with 1 character. 7 happened to be the first (or only one) in your directory. If you had files named 3 and 7, 3 would not have "worked" and 7 would have "worked".
Darrell