- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Script Variables
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
06-11-2003 11:18 AM
06-11-2003 11:18 AM
What I really need to know is how to write a variable off to a file or the environent so I can reference that same variable the next time the script runs from cron.
Thanks,
Jeff
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2003 11:21 AM
06-11-2003 11:21 AM
Re: Script Variables
One way to do it would be to write the variable to a file, and then use the dot command to source in that file at the start of your script. You could do something like this:
MYVAR=something
echo "MYVAR=${MYVAR}" >mysrc
And then at the beginning of your script do:
. mysrc
There are probably better ways to do it but that one comes to mind first.
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2003 11:25 AM
06-11-2003 11:25 AM
Re: Script Variables
do
ping -n 4 $x #command to execute on list elements
done
the file "list" would contain a
list of devices you wanted to ping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2003 11:29 AM
06-11-2003 11:29 AM
Re: Script Variables
You can make some file that will be
the configuration file and inside write on/off
let say : /etc/your-file.conf
Write inside on/off what you need and
is your script made cat to the file and
check if you get "on" or "off"
and work as you need to what you had.
Caesar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2003 11:33 AM
06-11-2003 11:33 AM
SolutionWrite your variable to a temporary file. To retrieve it read the temporary file into a variable. Thus:
# FILE=/tmp/myfile
# echo 48 > ${FILE}
...
[ -r ${FILE} ] && VAR=`< ${FILE}
...
The construct VAR=`< ${FILE}` is a very efficient method of reading a file into a variable.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2003 11:46 AM
06-11-2003 11:46 AM
Re: Script Variables
For that purpose, use something that actually does something on the remote host. We use secure shell here, and you should too. Here's why:
ssh $HOST "ls -l /etc/hosts"
if test "$?" -ne "0"
then
print "Houston, we have a problem on $HOST"
fi
Every morning at 8 AM, I have a cron job that iterates through a miniature HOSTS table and pretty much does the above. This gives management a warm fuzzy feeling that each host has been checked, and is up and running. A ping all by itself won't do that.
Chris