- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: another question for scripting
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
тАО03-04-2011 09:07 AM
тАО03-04-2011 09:07 AM
I have a script and an input file. I would like to declare some of those variable in the input file so each time I can just pass the input file to the script. This will save my time of trying to create 20 scripts for 20 servers.
For example, I can simply run
script.sh myinputfile.
The reason for that is because the input file will have set of variable define and will be different for all the machine.
Here is how myinputfile look like
myinputfile:
servername=Venus
serverowner=Alex
Serverapps="Oracle:Sun:ERP"
so when I run the script.sh it will take those variable define in myinputfile and execute the script accordingly.
What is the best way to do this?
Solved! Go to Solution.
- Tags:
- source
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-04-2011 09:14 AM
тАО03-04-2011 09:14 AM
Re: another question for scripting
Perhaps:
. myinputfile
Or, if you want to put the file name on the
shell script's command line:
. "$1"
Did I suggest "man sh"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-04-2011 09:15 AM
тАО03-04-2011 09:15 AM
Re: another question for scripting
shell script primer
or:
shell script tutorial
might also be helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-04-2011 09:15 AM
тАО03-04-2011 09:15 AM
Re: another question for scripting
You need to 'source' (read) the input file into your environment:
# . /myinputfile
Note carefully the dot ('.') followed by *whitespace* and then the name of the file containing the variables you want to import into your environment:
# cat ./mysh
#!/usr/bin/sh
. /myinputfile
echo "I am ${servername}"
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-04-2011 06:17 PM
тАО03-04-2011 06:17 PM
Re: another question for scripting
Do you have anything else in your input file other than variables?
The above sourcing solutions only expect shell commands there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-04-2011 07:07 PM
тАО03-04-2011 07:07 PM
Re: another question for scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-04-2011 07:19 PM
- Tags:
- scummy C shell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-05-2011 12:34 AM
тАО03-05-2011 12:34 AM
Re: another question for scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-05-2011 06:18 AM
тАО03-05-2011 06:18 AM
Re: another question for scripting
> yep source is the keyword and I manage do it right
And you will recall that "sourcing" was the term I used.
It would have helped both *you* and *us* if you had _defined_ your environment better. In this HP-UX forum, in the absence of stating otherwise, it is fair to assume that shell-related questions are for the POSIX shell ('/usr/bin/sh' or /sbin/sh') unless otherwise stated.
...JRF...