- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Run sql from a shell script
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-22-2006 02:52 AM
тАО08-22-2006 02:52 AM
Run sql from a shell script
...
...
echo "From: SDC" > /eis/data/poll.msg
echo "Subject: POLLING RESULTS " >>/eis/data/poll.msg
emailaddr=`isql -s sdc -<
Select Unique Lower(recipient), "RCP"
From email_ctrl
Where Upper(rptType) = "POLL"
And Upper(hold) <> "Y"
EOF`
people_cnt=0
for everyone in `echo $emailaddr`
do
echo "To: $everyone" >> /eis/data/poll.msg
people_cnt=`expr $people_cnt + 1`
done
if [ $people_cnt -gt 1 ]
then
cat /eis/data/poll.msg /eis/data/sitestat.txt | /usr/sbin/sendmail -t
fi
...
...
Randomly it failed in getting any recipients (if re-ran, it worked again!). I put the output of shell script to a log and noticed, when it was working, in the log:
Lockmode set.
34 row(s) retrieved.
When it failed, in the log:
kitpoll.sh[48]: /var/tmp/sh2806.1: Cannot find or open the file.
----------------------------------------------
The Database engine is Informix runing on HP-UX 11.11. What can I do to make sure it works perfect?
Thanks,
Chushia
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2006 02:59 AM
тАО08-22-2006 02:59 AM
Re: Run sql from a shell script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2006 02:59 AM
тАО08-22-2006 02:59 AM
Re: Run sql from a shell script
emailaddr=`isql -s sdc -<
Select Unique Lower(recipient), "RCP"
From email_ctrl
Where Upper(rptType) = "POLL"
And Upper(hold) <> "Y"
EOF`
Seems that your sql database connection is not working. You need to check return codes and stop this script when this happens.
The return code from processes is kept in the $? variable.
echo "steve"
echo $?
If I get a zero that means the echo steve statement was successful.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2006 03:31 AM
тАО08-22-2006 03:31 AM
Re: Run sql from a shell script
As for connection, I tested that if there is sql error it'd still result in a return value of 0. Plus, the fail reason would be written in log like : Database not found or no system permission;
or "The specified table (email_ctrl) is not in the database."
Thanks,
Chushia
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2006 05:49 AM
тАО08-22-2006 05:49 AM