- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Can anybody help me to understand the script and.....
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
тАО08-05-2002 01:04 AM
тАО08-05-2002 01:04 AM
I've a typical task, a shell script, may be written in AIX, need to convert to hp-ux.
following is the script,
----
Change script name to lower case
QUERY='echo $1 |tr "[A-Z]" "[a-z]".sql
#Create the body of SQL(OTXUP20.sql)
build ()
{
SQL='cat $YDEBTSQL/$QUERY'
cat $YDEBTSQL/insertCT.sql > $YDEBTSQL/OTXUP20.sql
if [ "$?" != "0" ]
then
exit 9
fi
echo "SQL" >> $YDEBTSQL/OTXUP20.sql
if ["$?" !="0"]
then
exit 9
fi
cat $YDEBTSQL/exit.sql >> YDEBTSQL/OTXUP20.sql
if ["$?" !="0"]
then
exit 9
fi
}
runit()
------
First I think need to understand, what exactly it is doing, then move to the next part...
Please ...
Thanks in Adv.
Regards
Shah
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-05-2002 01:15 AM
тАО08-05-2002 01:15 AM
Solution>>> seems to be a missing quote at the end.
>>> I prefer to use
>>> QUERY=$('echo $1 |tr "[A-Z]" "[a-z]".sql)
>>> although both will work.
>>>
>>> this bit just tr(anslates) $1
>>> $1 being the first arg of the script
>>> to lowercase.
>>>
>>> ie:
>>> scriptname hostname user port
>>> $0 $1 $2 $3
>>>
#Create the body of SQL(OTXUP20.sql)
build ()
{
SQL='cat $YDEBTSQL/$QUERY'
>>> $YDEBTSQL is obviously a directory name
>>> $QUERY is the filename we just lowercased
>>> $SQL is now the content of that file.
cat $YDEBTSQL/insertCT.sql > $YDEBTSQL/OTXUP20.sql
>>> same as cp $YDEBTSQL/insertCT.sql $YDEBTSQL/OTXUP20.sql
if [ "$?" != "0" ]
then
exit 9
fi
>>> command error codes are returned to the
>>> shell and referenced by echo $?
>>> no error = return code 0
>>> here your application/script, will return
>>> an error 9 if it can't do the previous
>>> operation.
echo "SQL" >> $YDEBTSQL/OTXUP20.sql
>>>
>>> this will redirect the text SQL
>>> into a newline in the file OTXUP20.sql
>>> common mistake is to:
>>> echo "SQL" > $YDEBTSQL/OTXUP20.sql
>>> that just creates a file with text SQL
>>> and 'erases' previous content of the file.
if ["$?" !="0"]
then
exit 9
fi
cat $YDEBTSQL/exit.sql >> YDEBTSQL/OTXUP20.sql
if ["$?" !="0"]
then
exit 9
fi
}
runit()
runit()
is referencing a function defined somewhere else in this script or in a referenced script.
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-05-2002 01:22 AM
тАО08-05-2002 01:22 AM
Re: Can anybody help me to understand the script and...
Then,it is just doing a cat of insertCT.sql,$QUERY and exit.sql and storing it in a single file i.e.getting the contents of the three files and storing it in OTXUP20.sql.
In the meanwhile it is checking for the status to be successful.
The script exits if one of the steps where it is doing a cat and storing to OTXUP20.sql fails.
Thanks
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-05-2002 01:57 AM
тАО08-05-2002 01:57 AM
Re: Can anybody help me to understand the script and...
Thanks Lot,
some times, we don't understand simple things, may be because of lack of patience.
You people are very good. great,,
Now I understand the script, but the following line,
echo "SQL" >> $YDEBTSQL/OTXUP20.sql
to me it is just appending the word "SQL" to $YDEBTSQL/OTXUP20.sql file.
or is it the script writer trying to store the content of SQL file to the above file?
...
Regards
Shah
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-05-2002 02:05 AM
тАО08-05-2002 02:05 AM
Re: Can anybody help me to understand the script and...
how about
echo "$SQL" >>/...
THanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-05-2002 02:17 AM
тАО08-05-2002 02:17 AM
Re: Can anybody help me to understand the script and...
SQL variable now contains the content of the Query file.
cat $YDEBTSQL/insertCT.sql > $YDEBTSQL/OTXUP20.sql
This is the same as a copy
echo "SQL" >> $YDEBTSQL/OTXUP20.sql
This echos the text
SQL
in a new last line of $YDEBTSQL/OTXUP20.sql
It possibly should be
echo "$SQL" >> $YDEBTSQL/OTXUP20.sql
in order that the SQL variable is referenced, but then
cat $YDEBTSQL/$QUERY >> $YDEBTSQL/OTXUP20.sql
does exactly the same thing..
possibly you want to have lots of tests done, and exist codes everywhere..
Later,
Bill