GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Shell Script help.
Operating System - HP-UX
1846210
Members
5081
Online
110255
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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-26-2001 09:08 AM
02-26-2001 09:08 AM
To the group.. I am trying to write a menu that a user can setup a database name variable with, without doing the
VARIABLE=variable;export VARIABLE everytime.
I wrote a script that I would assume would work, however when I echo the variable back the value is unset. I would appreciate anyone that might be able to see my mistake..
# SCRIPT BEGINS HERE..
clear
echo '
which database would you like to use:
a.) Elkhorn
b.) Ralston
c.) Papillion / LaVista
d.) Westside
e.) Arlington
f.) Blair
g.) Conestoga
h.) Ft Calhoun
i.) Gretna
j.) Valley
k.) Papillion/LaVista K
l.) Westside Foundation
m.) Millard
n.) ESU
Please select from one of the above: \c'
read choice
echo
case "$choice" in
a)export PEIDBNAME=elkfin;;
b)export PEIDBNAME=ralfin;;
c)export PEIDBNAME=plvfin;;
d)export PEIDBNAME=wstfin;;
e)export PEIDBNAME=alrfin;;
f)export PEIDBNAME=blrfin;;
g)export PEIDBNAME=confin;;
h)export PEIDBNAME=ftcfin;;
i)export PEIDBNAME=grtfin;;
j)export PEIDBNAME=valfin;;
k)export PEIDBNAME=plkfin;;
l)export PEIDBNAME=wsffin;;
m)export PEIDBNAME=mpsfin;;
n)export PEIDBNAME=esufin;;
esac
VARIABLE=variable;export VARIABLE everytime.
I wrote a script that I would assume would work, however when I echo the variable back the value is unset. I would appreciate anyone that might be able to see my mistake..
# SCRIPT BEGINS HERE..
clear
echo '
which database would you like to use:
a.) Elkhorn
b.) Ralston
c.) Papillion / LaVista
d.) Westside
e.) Arlington
f.) Blair
g.) Conestoga
h.) Ft Calhoun
i.) Gretna
j.) Valley
k.) Papillion/LaVista K
l.) Westside Foundation
m.) Millard
n.) ESU
Please select from one of the above: \c'
read choice
echo
case "$choice" in
a)export PEIDBNAME=elkfin;;
b)export PEIDBNAME=ralfin;;
c)export PEIDBNAME=plvfin;;
d)export PEIDBNAME=wstfin;;
e)export PEIDBNAME=alrfin;;
f)export PEIDBNAME=blrfin;;
g)export PEIDBNAME=confin;;
h)export PEIDBNAME=ftcfin;;
i)export PEIDBNAME=grtfin;;
j)export PEIDBNAME=valfin;;
k)export PEIDBNAME=plkfin;;
l)export PEIDBNAME=wsffin;;
m)export PEIDBNAME=mpsfin;;
n)export PEIDBNAME=esufin;;
esac
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2001 09:26 AM
02-26-2001 09:26 AM
Solution
If you just run the script (./scriptname) then the variable will not be exported globally for that user.
What you have to do is do a '. scriptname' (there is a space between the . and the scriptname) or a 'source scriptname' depending on which shell you are using. Doing this will make it so that the variable is exported to the users shell. You can then do an 'echo $PEIDBNAME' and it should return the appropriate value.
What you have to do is do a '. scriptname' (there is a space between the . and the scriptname) or a 'source scriptname' depending on which shell you are using. Doing this will make it so that the variable is exported to the users shell. You can then do an 'echo $PEIDBNAME' and it should return the appropriate value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2001 09:39 AM
02-26-2001 09:39 AM
Re: Shell Script help.
Patric is correct. Run the script is a . in front.
ie....
../striptname
ie....
.
If I had only read the instructions first??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2001 11:29 AM
02-26-2001 11:29 AM
Re: Shell Script help.
You could use alias in .profile to simplify
alias setdb=". ./scriptfile"
Then the user only enters
setdb
alias setdb=". ./scriptfile"
Then the user only enters
setdb
There be dragons...
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2026 Hewlett Packard Enterprise Development LP