![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how do i get current bandwidth usage via shell script? | scarfake | Shell Programming and Scripting | 2 | 05-25-2008 10:27 PM |
| using shell script to telnet | ricky katix | SUN Solaris | 6 | 01-16-2008 02:27 PM |
| telnet shell script on red hat 9 cmd line only | kypeswith | Shell Programming and Scripting | 3 | 10-14-2007 04:22 PM |
| shell script extended usage... | joerg535 | UNIX for Dummies Questions & Answers | 1 | 08-24-2007 10:02 AM |
| telnet & su in shell script | vastare | Shell Programming and Scripting | 1 | 01-19-2006 11:47 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
usage of telnet in shell script
Hi All,
How could I use telnet to connect to Primary Host in the below shell script: Could I use: ( echo user sleep 2 echo password sleep 2 echo "ls ~" sleep 2 echo "exit" ) | telnet hostname #----------------------------------------------------------------------------- # Use SQL*Plus to query the MAX(SEQUENCE#) from both databases V$LOG_HISTORY # view. If the STANDBY appears to be falling behind, then send alert mail.. #----------------------------------------------------------------------------- OutFile=/tmp/stdby_chk_$$.out sqlplus -s /nolog << __EOF__ > ${OutFile} 2>&1 whenever oserror exit 99 connect / as sysdba set verify off whenever sqlerror exit 6 col logseq_on_standby new_value V_STDBY_LOGSEQ select /*+ rule */ max(h.sequence#) logseq_on_standby from v\$log_history h, v\$parameter p where h.thread# = to_number(decode(p.value,'0',1,p.value)) and p.name = 'thread'; col filecnt new_value V_STDBY_FILECNT select count(*) filecnt from v\$datafile; whenever sqlerror exit 7 connect ${_PriUnPwd} whenever sqlerror exit 8 col logseq_on_primary new_value V_PRIMARY_LOGSEQ select /*+ rule */ max(h.sequence#) logseq_on_primary from sys.v_\$log_history h, sys.v_\$parameter p where h.thread# = to_number(decode(p.value,'0',1,p.value)) and p.name = 'thread'; col filecnt new_value V_PRIMARY_FILECNT select count(*) filecnt from v\$datafile; whenever sqlerror exit 9 begin if &&V_STDBY_LOGSEQ < &&V_PRIMARY_LOGSEQ - 2 then -- if &&V_PRIMARY_FILECNT > &&V_STDBY_FILECNT then -- raise_application_error(-20001, '${_StdbyOraSid} is falling behind; datafile(s) were added to PRIMARY'); -- elsif &&V_PRIMARY_FILECNT < &&V_STDBY_FILECNT then -- raise_application_error(-20002, '${_StdbyOraSid} is falling behind; datafile(s) were dropped from PRIMARY'); -- else -- raise_application_error(-20000, '${_StdbyOraSid} is falling behind.'); -- end if; -- end if; end; / exit success __EOF__ # #----------------------------------------------------------------------------- # Based on error code from SQL*Plus, compose an error message... #----------------------------------------------------------------------------- integer _Rtn=$? case ${_Rtn} in 0) rm -f ${OutFile} ;; # ...everything is OK! 6) _Echo failure "Query of V\$LOG_HISTORY on STANDBY failed\n\n`cat ${OutFile}`\n" ;; 7) _Echo failure "unable to connect to PRIMARY" ;; 8) _Echo failure "Query of V\$LOG_HISTORY on PRIMARY failed\n\n`cat ${OutFile}`\n" ;; 9) _Echo failure "STANDBY is falling behind PRIMARY\n\n`cat ${OutFile}`\n" ;; *) _Echo failure "SQL*Plus failed\n\n`cat ${OutFile}`\n" ;; esac rm -f ${OutFile} # #----------------------------------------------------------------------------- # Done! #----------------------------------------------------------------------------- exit 0 Thanks for your time! Regards, |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|