I created a shell script to record server temperature. When I manually run script it works fine with no error message. But when I create a cron job, my script fails with error message (standard_in)1:syntax error. I figured out the bc utility is causing the error message. Below is my script.
Inside of fahrenheit variable I tried different variations of the bc command and nothing seems to work.
I have tried:
and nothing seems to work.
I've declared celsius as a variable by using ilo5501-step5.csv file. There is a numerical value with a decimal inside of ilo5501-step5.csv file. I'm using that value converting it to fahrenheit by calling celsuis inside of fahrenheit variable.
What is wrong with bc command? Em I using the bc command incorrectly when using cron to run script.
Last edited by RudiC; 07-19-2018 at 03:44 AM..
Reason: Obfuscated password
Sure it's bc? Pls show your cron entry, and also the contents of the celsius variable, and the step5 file.
Are your aware that most of your convoluted processing could be done in one single script, e.g. awk or perl?
Are there lines beyond 22 in the original file?
I would expect echo '(1.8*$celsius+32)' | tr -d '\n' | bc -l to give you the diagnostic message you showed us since bc input needs to be a text file and, by stripping off the <newline> character with the tr element in your pipeline, bc is not getting a text file as input.
You should not get that error with echo "1.8*$celsius+32" | bc -l or with echo "1.8*$celsius+32" | bc, but you might get a different error if the celsius variable has not been set to a numeric string value.
Assuming you're trying to get a floating point result, if you have a 1993 or later version of ksh available on your system (in addition to bash), you could use the much more efficient:
This User Gave Thanks to Don Cragun For This Post:
Sure it's bc? Pls show your cron entry, and also the contents of the celsius variable, and the step5 file.
Are your aware that most of your convoluted processing could be done in one single script, e.g. awk or perl?
Are there lines beyond 22 in the original file?
Thanks for your reply @RudiC.
The reason why I thought is was bc utility, when I received "(standard_in)1:sytax error" I noticed fahrenheit variable inside of ilo-step6.csv file isn't converted to Fahrenheit value. But after more testing my assumption was incorrect.
I'm almost convinced its not bc causing error code. I notice when I receive "(standard_in)1:sytax error" I'm not getting a temperature reading via SSH server. I know for a fact server isn't down. Which leads me to believe that SSH is failing to connect to server. I'm still diagnosing issue. Any new finding I will post my results.
Below is my cron entry:
Below is contents of celsuis variable in step5 file:
I wasn't aware all my bash shell script could be done in one single script using awk and perl. That's interesting. I definitely need to learn more awk commands. I'll look into perl programming soon. I'm always trying to improve in bash shell. I'm still learning and having fun. Thank you.
Pls run the cron job with the -x (xtrace) bash option and post the output.
And, how far would
get you? Note: this is untested; for a test pls post the sshpass command's full output.
I ran xtrace and result is below:
Looks like SSH is not connecting to the server and extracting temperature value. Going to look into why SSH isn't connecting the server. Also going to look into using a different SSH command.
I ran awk command and I received this output below:
I'm getting syntax error at
part.
Last edited by SysAdminRialto; 07-20-2018 at 10:48 AM..
Sorry for the ) too many; as said I didn't have a chance to test as I was on a - huaaa - windows machine. Remove and try again.
Would it be possible the file names have \rin them as well? Your xtrace seems to have some indication.
SCO OSR 507, user's shell is old Bourne sh
The same command is OK when run using now, but fails when run in cron, see below:
1) using now, see how it worked and I see resulting DT=2018 in the mail
$ at now
{ dt=`/usr/gnu/bin/date '+%Y'`; echo "DT=$dt"; }
job 1522867418.a-6605:0 at Wed... (2 Replies)
Hello,
I have another problem with my script. Please accept my apologies, but I am really nooby in sh scripts. I am writing it for first time.
My script:
returned=`tail -50 SapLogs.log | grep -i "Error"`
echo $returned
if ; then
echo "There is no errors in the logs"
fi
And after... (10 Replies)
Hi,
I am trying to make a script that tries to compare two values and print if one is greater than another. It seems to return a (standard_in) 1: parse error at times.
#!/bin/sh
a= awk '{print $1}' file1.txt
b= awk '{print $1}' file2.txt
c= awk '{print $1}' file3.txt
x= awk '{print... (5 Replies)
Below part of script, is working fine sometimes and gives error sometime.
I am doing float operations, checking if x > y.
##########CODE##########
THRESHOLD="1.25"
ratio=$( echo "scale=2; ${prev}/${current}" | bc )
if ; then
split_date=`echo ${line} | cut -d, -f2`
fi ... (9 Replies)
Hi all,
Could someone please to tell me when do we exactly get the below error and how to get rid of it.
I am unable to trace the error.
(standard_in) 1: parse error
Thanks in advance !! (4 Replies)
Dears
if i want to run this job every Saturday at 6 AM that will be the code
* 6 * * 1 cd /export/home/jenova ; ls -ltr >> $HOME/jenova_dir (2 Replies)
--------------------------------------------------------------------------------
Hello, help me please.
I am trying to create a mksysb bakup using nim. I am geting this error, how to correct it ? :
Command : failed stdout: yes stderr: no... (9 Replies)
hi there
i write one awk script file in shell programing
the code is related to dd/mm/yy to month, day year format
but i get an error
please can anybody help me out in this problem ??????
i give my code here including error
awk `
# date-month -- convert mm/dd/yy to month day,... (2 Replies)