- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Environment Variable Count
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
Discussions
Discussions
Forums
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
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
тАО08-14-2002 03:53 PM - last edited on тАО10-22-2012 12:08 AM by Maiko-I
тАО08-14-2002 03:53 PM - last edited on тАО10-22-2012 12:08 AM by Maiko-I
Hi all,
What I am trying to do is set an environment variable.
SEQ=20000
This variable will change when the user runs a specific report.
run no 1 SEQ=20001
run no 2 SEQ=20002
What I want to do is retain this new value so as next time the user logs on the sequence continues
SEQ=20003
P.S. This thread has been moved from HP-UX > General to HP-UX > languages - HP Forums Moderator
Solved! Go to Solution.
- Tags:
- variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-14-2002 04:44 PM
тАО08-14-2002 04:44 PM
Solution# cat /dir/SEQ
2002
# export SEQ=`cat /dir/SEQ`
# echo $SEQ
2002
Then when you increment SEQ you do a:
echo $SEQ > /dir/SEQ
and the new value will then be kept in the file for the next run.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-14-2002 06:33 PM
тАО08-14-2002 06:33 PM
Re: Environment Variable Count
Patrick's is good if you are keeping the sequence per user (only one copy of the script running at a time will update the file that records the sequence number). If that is not true, you will need to come up with a solution that is better than "the last person to write the file wins".
If so, here are two suggestions: 1) use a directory and touch a file with the sequence number in the name (be careful of how ls(1) lists numbered file names -- not necessairly in numerical order), get the last file in the list, increment the number and touch the file name (only if it does not already exist). 2) use a single file, get the last number off the bottom, increment it, append it to the file, and make sure it is not a duplicate (unfortunately, I ran out of ideas on how to deal with a duplicate -- sigh). 3) If you run your sequencing script as an LP spool script, you could use the job number...
-dlt-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-15-2002 03:05 AM
тАО08-15-2002 03:05 AM
Re: Environment Variable Count
In order to make sure not to have duplicate you could use the following method :
while :
do
mkdir /tmp/get_new_seq 1>/dev/null 2>/dev/null
if [ $? = 0 ]
then
break
fi
done
export SEQ=`cat /dir/sequence_number`
let NEXTSEQ=SEQ+1
echo $NEXTSEQ > /dir/sequence_number
unset NEXTSEQ
rmdir /tmp/get_new_seq 1>/dev/null 2>/dev/null
As the loop will continue until the directory is created, 2 users could not read /dir/sequence_number at the same time.
Hope that will help.
Christophe.