- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Input to command automatically
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
Forums
Discussions
Discussions
Discussions
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
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-11-2010 01:14 AM
03-11-2010 01:14 AM
Input to command automatically
i want to give input to a command automatically.
for Example:
Normally i have to run the command say "x" for intiating sql query and afterwards ihave to give the sql commands and press enter
#x
SQL>select * from data_detail;
quit;
#
i need to auomate this .Please help me
Cheers !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2010 01:38 AM
03-11-2010 01:38 AM
Re: Input to command automatically
If you use sqlplus (x=sqlplus), you could make a sql script (your select/insert/whatever/quit will go there) and then se something like this:
sqlplus -s '/ as sysdba' @yourscript.sql
If you script would use some variable, you can add that variable at the end of this command like this:
sqlplus -s '/ as sysdba' @yourscript.sql $variable1
In your script.sql you can access that variable by $1.
Horia.
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2010 01:39 AM
03-11-2010 01:39 AM
Re: Input to command automatically
Sorry, it is &1. Read manual for sqlplus.
Horia.
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2010 04:40 AM
03-11-2010 04:40 AM
Re: Input to command automatically
You could use a here-document:
sqlplus <
- Tags:
- here doc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2010 05:34 AM
03-11-2010 05:34 AM
Re: Input to command automatically
# cat sample.sh
echo "..."
sqlplus / sample.sql
ERR=$(grep 'ORA-' sample.log)
if [ "$ERR" = "" ]
then
echo "SAMPLE: OK."
else
echo "sample: ERROR"
exit 3
fi
# cat sample.sql
spool sample.log
select * from data_detail;
spool off
exit;
Rgs,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2010 12:25 AM
03-12-2010 12:25 AM
Re: Input to command automatically
don't use sqlplus user/password but:
sqlplus
conn user/password
....
exit
reason why is that by 'ps -ef|grep [s]lplus' in the first way it's possible to cach database password!!
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2010 12:28 AM
03-12-2010 12:28 AM
Re: Input to command automatically
don't use sqlplus user/password but:
sqlplus
conn user/password
....
exit
reason why is that by 'ps -ef|grep [s]qlplus' in the first way it is possible to cach database password!!
HTH,
Art