Stty: : No such device or address

hi,

i am trying to execute a script through Cron, then everytime it is redirecting a message
stty: : No such device or address
Unmatched `

here is the cron entry:

35,40,45,50,55 04,05 07 08 * /uv1402/u207/home/bravodba/bestdbscript/shscriptfiles/bravo_main_refresh.sh

while the script is running pretty fine ehile running through command prompt. Please suggest.

Try to call the shell instead:

35,40,45,50,55 04,05 07 08 * /path/to/sh /uv1402/u207/home/bravodba/bestdbscript/shscriptfiles/bravo_main_refresh.sh

If sh is bash, then use bash.

Oh yes. The problem is that you're no longer calling the script on a terminal making stty show that message so my suggestion above won't really help sorry. Perhaps modifying the script to work with non-terminal input and output might help.

Perhaps using a tty emulator or virtualizer like screen, expect, or ttyrec and the likes would help perhaps.

i couldn't get what you are trying to say, please explain briefly

When running with cron, remember that you don't actually have a terminal. If your script issues stty commands, then you will get this error. You either have to handle the error, live with it or exclude it in the cron entry.

So you could in the script find and edit lines like this:-

stty erase ^H 2>/dev/null

Check any .profile, /etc/profile and called / sourced scripts too, perhaps to include .kshrc .bash_rc or similar.

In your cron entry:-

35,40,45,50,55 04,05 07 08 * /uv1402/u207/home/bravodba/bestdbscript/shscriptfiles/bravo_main_refresh.sh 2>&1|grep -v "^stty:"

I hope that this helps

Robin
Liverpool/Blackburn
UK

i agree, this will help me to hide stty : : no such device or address error.

but it seems to me that actual error is coming while establishing the connection and when it finds ` symbol. here is the initial code of my script.

#!/bin/csh

stty erase ^H 2>/dev/null

`sqlplus -s $ORACLE_USER/$ORACLE_PASS@$ORACLE_SID   << EOF > sql_output.txt
                select count(*) from bravo_statistics
                where trunc(time_stamp)=trunc(sysdate)
                and description in ('BEGIN NIT','END MR');
EOF`

and i have modified cron as per above suggestion.

20,25,30,35,40,44,50,55 04,05,6 07 08 * /uv1402/u207/home/bravodba/bestdbscript/shscriptfiles/bravo_main_refresh.sh  2>&1|gr
ep -v "^stty:"

it is a .sh extension script, so please let me know what needs to be corrected here?

Why are you using backquotes to execute SQLPlus? That's quite pointless. SQLPlus is already executable.

You could also just check for the terminal type in your profile / script:

$ echo $TERM
xterm-256color

$ crontab -l
* * * * * echo $TERM > /tmp/TERM.txt

...

$ cat /tmp/TERM.txt
dumb

everything was working properly when i was trying to run the script manually, but now i have removed ` sign from sqlplus

sqlplus -s $ORACLE_USER/$ORACLE_PASS@$ORACLE_SID   << EOF > sql_output.txt
                select count(*) from bravo_statistics
                where trunc(time_stamp)=trunc(sysdate)
                and description in ('BEGIN NIT','END MR');
EOF
big_cnt=`sed -n '4p' sql_output.txt`
if [ $big_cnt -eq 0 ] ; then

and it is giving below error now:

Try using set big_cnt=$(sed -n '4p' sql_output.txt)

You could do yourself a bigger favour by not using CSH :slight_smile:

whether i should use csh or not, but 1 thing is sure that by removing ` sign from sqlplus, it has stopped writting in the output file.

sqlplus -s $ORACLE_USER/$ORACLE_PASS@$ORACLE_SID   << EOF > sql_output.txt
                select count(*) from bravo_statistics
                where trunc(time_stamp)=trunc(sysdate)
                and description in ('BEGIN NIT','END MR');
EOF

and at last it is giving

error

This is likely a result of the C-Shell's ad-hoc parser which handles quotes abysmally badly.

if i get a perfect way to handle ` sign in my script then i am all set, please suggest.

There is nothing wrong with the SQLPlus. The backquotes are not required. The error comes from elsewhere.

Also the syntax of your if statement is Bourne shell... not C-Shell.

if ( $big_cnt == 0 ) then

"

why it is not generating any error while running manually instead of crontab?

If you're running this through cron you need to ensure that your environment is properly configured (usually by sourcing your ~/.profile and setting up your Oracle environment, etc.).

I've already given you my suggestion: Stop using the C-Shell.

alike other script in the same directory, i am using this

in the begining of my script. what else do i need to do to get profile file working properly?

You haven't shown us your entire script. Of the six lines you did show, one was Bourne shell, and you seem to have wrongly deduced that the error is somewhere it is not.

I haven't used C-Shell in the best part of 20 years - and for good reason - it's rubbish, really rubbish! Just because "other scripts" in the directory uses it doesn't mean you have to!

Please post your entire script so we can see the big picture instead of doing this piecemeal.

here is the entire script:

#!/bin/csh

# ***  Lovely Sethi 08/2013  ***
#  This process executes the BRAVO_MAIN_REFRESH.sql
#
#  This file should be scheduled in CRONTAB to run each Big run.

stty erase ^H 2>/dev/null

`sqlplus -s $ORACLE_USER/$ORACLE_PASS@$ORACLE_SID   << EOF > sql_output.txt
                select count(*) from bravo_statistics
                where trunc(time_stamp)=trunc(sysdate)
                and description in ('BEGIN NIT','END MR');
EOF`
big_cnt=`sed -n '4p' sql_output.txt`
#big_cnt=$(sed -n '4p' sql_output.txt)

if [ $big_cnt -eq 0 ] ; then

`sqlplus -s $ORACLE_USER/$ORACLE_PASS@$ORACLE_SID   << EOF >> sql_output.txt
                select nvl(description,'0') from bravo_statistics
                where trunc(time_stamp)=trunc(sysdate)
                and description='END CAT';
EOF`
`sqlplus -s $ORACLE_USER/$ORACLE_PASS@$ORACLE_SID   << EOF >> sql_output.txt
                select count(*) from mrs.bill_cal
                where trunc(actual_run_date)=trunc(sysdate)-19;
EOF`
end_ct=`sed -n '9p' sql_output.txt`
#end_ct=$(sed -n '9p' sql_output.txt)
emtr_cnt=`sed -n '14p' sql_output.txt`
#emtr_cnt=$(sed -n '14p' sql_output.txt)
if [ "$end_ct" = "END CAT" ] && [ $emtr_cnt -eq 1 ] ;  then
sqlplus $ORACLE_USER/$ORACLE_PASS@$ORACLE_SID @/uv1402/u207/home/bravodba/bestdbscript/sqlscriptfiles/BRAVO_MAIN_REFRESH.sql
/uv1402/u207/home/bravodba/bestdbscript/shscriptfiles/sendmailanalysisrefresh.sh
echo "value found"
fi

fi

Now it's Bash??

Are the Oracle variables set up in the ~/.bash_profile?

$ cat scr1
#!/bin/bash

# ***  Lovely Sethi 08/2013  ***
#  This process executes the BRAVO_MAIN_REFRESH.sql
#
#  This file should be scheduled in CRONTAB to run each Big run.

. ~/.bash_profile 2> /dev/null >&2

sqlplus -s $ORACLE_USER/$ORACLE_PASS@$ORACLE_SID   << EOF > sql_output.txt
                select count(*) from bravo_statistics
                where trunc(time_stamp)=trunc(sysdate)
                and description in ('BEGIN NIT','END MR');
EOF
big_cnt=$(sed -n '4p' sql_output.txt)

if [ $big_cnt -eq 0 ] ; then

  sqlplus -s $ORACLE_USER/$ORACLE_PASS@$ORACLE_SID   << EOF >> sql_output.txt
                select nvl(description,'0') from bravo_statistics
                where trunc(time_stamp)=trunc(sysdate)
                and description='END CAT';
EOF

  sqlplus -s $ORACLE_USER/$ORACLE_PASS@$ORACLE_SID   << EOF >> sql_output.txt
                select count(*) from mrs.bill_cal
                where trunc(actual_run_date)=trunc(sysdate)-19;
EOF

  end_ct=$(sed -n '9p' sql_output.txt)
  emtr_cnt=$(sed -n '14p' sql_output.txt)

  if [ "$end_ct" = "END CAT" ] && [ $emtr_cnt -eq 1 ];  then
    sqlplus $ORACLE_USER/$ORACLE_PASS@$ORACLE_SID @/uv1402/u207/home/bravodba/bestdbscript/sqlscriptfiles/BRAVO_MAIN_REFRESH.sql
    /uv1402/u207/home/bravodba/bestdbscript/shscriptfiles/sendmailanalysisrefresh.sh
    echo "value found"
  fi
fi

$ bash -n scr1
(no output - syntax is valid)

I see you swiftly edited your post to change

#!/bin/bash

to

#!/bin/csh

.

Which is it???

The script you posted is Bourne shell-like NOT C-shell.

ahh!! i was doing some experiment. actually it is csh