- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How set variable in scripts?
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
12-11-2007 10:32 PM
12-11-2007 10:32 PM
I am running one scripts:
myscripts.scr
in this scripts i am caling one other scripts
say "otherscript.scr"
which should set some flag say
set_flag=1 or 0 as per condition.
After that i want to use this flag again in main script(myscripts.scr) like
if [ set_flag = 1 ] ; then
echo ......
fi;
Basically it is something like
myscripts.scr
(
...code..
otherscript.scr
(
this will set flag
)
if set_flag = 1 then ...
how to define this set_flag variable. If i export it then it will not be updated by inside script.
Can some one please suggest how to do this?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2007 10:44 PM
12-11-2007 10:44 PM
Re: How set variable in scripts?
let set_flag=1
if [ $set_flag -eq 1 ]; then
echo set_flag is 1
else
echo set_flag is $set_flag
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2007 10:53 PM
12-11-2007 10:53 PM
Re: How set variable in scripts?
I will explain my question again.
run myscripts.scr (
..........code start......
call other script.scr
(
------code start-----
if today is first working day then
set_flag = 1
else set_flag=0
-----code completed-----
)
---control back to main scripts
if [ set_flag = 1 ]; then
echo "it is first working day"
else
echo "it is not first working day"
...........code completed ......
Then how to define set_flag in main code so that it can be changed by inside script and result be available again for main script.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2007 11:08 PM
12-11-2007 11:08 PM
Solutionmyscript.scr
(
...
otherscript.scr
set_flag=$?
if [ $set_flag -eq 1 ]; then
echo "it is first working day"
else
echo "it is not first working day"
fi
...
)
otherscript.scr
(
...
if [ today is first working day ]; then
let set_flag=1
else
let set_flag=0
fi
...
return $set_flag
)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2007 12:15 AM
12-12-2007 12:15 AM
Re: How set variable in scripts?
You can set the exit status with return and test $?.
You can echo something and capture the output in the caller:
var=$(therscript.scr)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2007 01:39 AM
12-12-2007 01:39 AM
Re: How set variable in scripts?
I got answer from Sendman's reply. My problem got solved.
Thanks again