- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Unix Script updating a text file
Categories
Company
Local Language
Forums
Discussions
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Knowledge Base
Forums
Discussions
- Cloud Mentoring and Education
- Software - General
- HPE OneView
- HPE Ezmeral Software platform
- HPE OpsRamp
Knowledge Base
Discussions
Forums
Discussions
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
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-06-2001 06:27 AM
08-06-2001 06:27 AM
I have a backup application called Netbackup
and I need to pass parameters (the name of each server to backup) to an existing
text file.
SERVER= sundance
CLIENT_NAME = sundance
How do I go about updating the CLIENT_NAME with
arbitrary parameters ?
In other words, I'm not sure how to go about
updating a text file rather than creating a
new file each time the scripts runs..
I really appreciate the help.
Thanks,
Laurie
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2001 06:35 AM
08-06-2001 06:35 AM
SolutionSimply call your script with parameter
netbackup server1
in netbackup substitute CLIENT_NAME with the passed parameter which is named $1
CLIENT_NAME = $1
and off you go
egards
Rainer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2001 06:40 AM
08-06-2001 06:40 AM
Re: Unix Script updating a text file
If you had a text file called "template", which had the following
server=sundance
client_name=xxxxxx
Then if you built the following script
#!/usr/bin/sh
for client in groucho harpo chico zeppo ;
do sed "s/xxxxxx/$client/" newfile
netbackup
Then this would create a text file for each client stations (named after the Marx brothers) and run the netbackup command passing the file with the proper client name in each.
Hope this helps.
-- Rod H
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2001 06:41 AM
08-06-2001 06:41 AM
Re: Unix Script updating a text file
I am assuming that netbackup is script and it opens file names.txt which has server and client_name information.
run netbackup with argument client name
#./netbackup sachin
now script netbackup knows $1=sachin
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2001 06:44 AM
08-06-2001 06:44 AM
Re: Unix Script updating a text file
There are tons of ways to do this but all involve using the shell, awk, perl, or even C to build your text file 'on the fly'.
I suspect I would do this is using command line args:
something like this:
#!/usr/bin/sh
STAT=0
PROG=$0
if [ $# -ge 2 ]
then
server=$1
shift
client=$1
shift
echo "SERVER=${server}"
echo "CLIENT_NAME=${client}"
# add what ever else you need with echo's
else
echo "${PROG} requires at least 2 args" >&2
STAT=255
fi
exit $STAT
You would then use it like this:
buildfile.sh sundance butch > myfile
Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2001 06:48 AM
08-06-2001 06:48 AM
Re: Unix Script updating a text file
sed '/CLIENT_NAME/d' configfile > configfile.out
echo "CLIENT_NAME = newclient" >> configfile.out
mv configfile.out configfile
There are several ways to do it.
...jcd...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2001 06:51 AM
08-06-2001 06:51 AM
Re: Unix Script updating a text file
1. Create a text file with all your servers that that you want to backup ( example : serversFile.txt ).
2. Call your netbackup script using parameter serversFile.txt like :
# netbackup serversFile.txt .
3.
for currServer in `cat $1`
do
CLIENT_NAME=$currServer
... commands ....
done
4.
exit 0
Magdi