Find the answer to your Linux question:
Results 1 to 2 of 2
I have made a autoexpect script which calls a script which requires a few imputs to get the status of some database replication, as seen below. it works fine when ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2011
    Posts
    3

    Autoexcept and crontab job


    I have made a autoexpect script which calls a script which requires a few imputs to get the status of some database replication, as seen below. it works fine when i call it but it has problems with crontab

    This is what happens when i run it.

    -bash-3.00# ./replications.exp
    spawn su -l cworks /opt/installtemp/DBMaint3-H3C-V2.1/dbmaint.sh
    Database maintananence Utility
    installing operation files
    Please choose an operation
    1) Check replication status
    2) Clear any hung database jobs
    3) Update call log statistics
    4) Fix replication jobs
    5) Drop replication
    6) Check Data consistency between sites
    7) Fix data consistency issues
    Creat replication jobs
    0) Exit
    enter #: 1
    Previous Site Data?
    siteID: 1
    remoteIP: 172.16.2.4
    use this data?[y/N]: y
    Using existing data!
    Checking Replication

    Output from /tmp/DBmaint.log
    09-06-11 15:14:06 -- Checking Replication!
    09-06-11 15:14:06 --- Deftran count: 0

    09-06-11 15:14:06 --- Checking link: CWBES.VCXVCXSEC.COM
    09-06-11 15:14:06 --- Deftrandest count for link: 0
    09-06-11 15:14:06 --- Deferror count from link: 0
    09-06-11 15:14:06 --- Push Job num: 42
    09-06-11 15:14:06 --- last run: 09-06-11 14:20:14
    09-06-11 15:14:06 --- this run: 09-06-11 15:07:17
    09-06-11 15:14:06 --- next run: 09-06-11 14:40:17
    09-06-11 15:14:06 --- broken: N
    09-06-11 15:14:06 --- failures: 0
    09-06-11 15:14:06 --- description: declare rc binary_integer; begin rc := sys.dbms_defer_sys.push(destination=>'CWBES.VCXVCX SEC.COM', stop_on_error=>FALSE, execution_seconds=>2400, delay_seconds=>1200, parallelism=>1); end;

    09-06-11 15:14:06--- Purge Job num: 41
    09-06-11 15:14:06--- last run: 09-06-11 15:13:22
    09-06-11 15:14:06--- this run:
    09-06-11 15:14:06--- next run: 09-06-11 15:23:22
    09-06-11 15:14:06--- broken: N
    09-06-11 15:14:06--- failures: 0
    09-06-11 15:14:06--- description: declare rc binary_integer; begin rc := sys.dbms_defer_sys.purge( purge_method=>2, transaction_count=>25000); end;

    the exp script is as follows:


    set timeout -1
    spawn su -l cworks /opt/installtemp/DBMaint3-H3C-V2.1/dbmaint.sh
    match_max 100000
    expect -exact "\[H\[2JDatabase maintananence Utility\r
    installing operation files\r
    Please choose an operation\r
    1) Check replication status\r
    2) Clear any hung database jobs\r
    3) Update call log statistics\r
    4) Fix replication jobs\r
    5) Drop replication\r
    6) Check Data consistency between sites\r
    7) Fix data consistency issues\r
    Creat replication jobs\r
    0) Exit\r
    enter #: "
    send -- "1\r"
    expect -exact "1\r
    Previous Site Data?\r
    siteID: 1\r
    remoteIP: 172.16.2.4\r
    use this data?\[y/N\]: "
    send -- "y\r"
    expect eof

    the crontab is as follows:

    17 15 6 * * /opt/installtemp/health/Auto_check.health >/dev/null 2>&1

    the Auto_check.health file has the follow:

    NOW=$(date +"%B-%Y")
    /opt/installtemp/health/replications.exp > /opt/installtemp/health/$NOW.log

    and the result of the scrip when exexcuted via crontab is:

    "
    spawn su -l cworks /opt/installtemp/DBMaint3-H3C-V2.1/dbmaint.sh
    TERM environment variable not set.
    Database maintananence Utility
    installing operation files
    Please choose an operation
    1) Check replication status
    2) Clear any hung database jobs
    3) Update call log statistics
    4) Fix replication jobs
    5) Drop replication
    6) Check Data consistency between sites
    7) Fix data consistency issues
    Creat replication jobs
    0) Exit
    enter #:
    "

    Any ideas how i can get a crontab job to call the dbmaint.sh script and put in the required details and put the put put into a text file. the methord doesn't need to use autoexpect, this was the only way i knew how.

    Any help would be great.
    Cheers

  2. #2
    Banned
    Join Date
    Feb 2010
    Posts
    31
    I am guessing, but it is probably a problem with not having a TTY.
    Can you just copy the shell script: dbmaint.sh to another location (like /usr/local/bin) and modify it so that it has all the questions answered and does not require interaction? Presumably this is just a shell script (based on the .sh extension) and should be easy enough to just modify so when called with cron it does not need any keyboard interaction.
    Last edited by oz; 09-24-2011 at 01:24 PM. Reason: SPAM removal

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •