Sponsored Content
Top Forums Shell Programming and Scripting (standard_in)1:syntax error using bc with Cron Post 303020374 by SysAdminRialto on Tuesday 17th of July 2018 11:12:33 PM
Old 07-18-2018
(standard_in)1:syntax error using bc with Cron

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.

Code:
#!/bin/bash 


export SSHPASS=xxxxxxxxxxxx

# Connecting to DRESX iLO host via SSH
sshpass -e ssh -oBatchMode=no Administrator@192.168.15.71 show system1/sensor3 >> /usr/local/bin/Production/Templinegraph-script/DRESX5501/ilo5501-step1.csv

# Removing lines not needed from ilo5501-step1.csv file
sed '1,12 d;14,22 d' /usr/local/bin/Production/Templinegraph-script/DRESX5501/ilo5501-step1.csv > /usr/local/bin/Production/Templinegraph-script/DRESX5501/ilo5501-step2.csv

# Grabbing data I want after = sign from ilo5501-step2.csv and creating new file new CSV named step3.csv
sed 's/.*[=] *//' /usr/local/bin/Production/Templinegraph-script/DRESX5501/ilo5501-step2.csv > /usr/local/bin/Production/Templinegraph-script/DRESX5501/ilo5501-step3.csv

# Turning multiple lines into one line with comma separated
paste -d, -s /usr/local/bin/Production/Templinegraph-script/DRESX5501/ilo5501-step3.csv > /usr/local/bin/Production/Templinegraph-script/DRESX5501/ilo5501-step4.csv

# Removing ^M control M character from ilo5501-step4.csv
tr -d '\r' < /usr/local/bin/Production/Templinegraph-script/DRESX5501/ilo5501-step4.csv > /usr/local/bin/Production/Templinegraph-script/DRESX5501/ilo5501-step5.csv

# Celsius variable, calling step5.csv and making file into variable
celsius=$(</usr/local/bin/Production/Templinegraph-script/DRESX5501/ilo5501-step5.csv)

# Performing Celsius to Fahrenheit conversion
fahrenheit=$(bc <<< "1.8*$celsius+32")

# Sending Fahrenheit conversion to step6.csv
echo "$fahrenheit" > /usr/local/bin/Production/Templinegraph-script/senddb/ilo-step6.csv

Inside of fahrenheit variable I tried different variations of the bc command and nothing seems to work.

I have tried:
Code:
fahrenheit=$(echo '(1.8*$celsius+32)' | tr -d '\n' | bc -l)

Code:
fahrenheit=$(echo "1.8*$celsius+32" | bc -l)

Code:
fahrenheit=$(echo "1.8*$celsius;+32" | bc)

Code:
fahrenheit=$(bc <<<  "scale=2; 1.8*$celsius+32")

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
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

awk Shell Script error : "Syntax Error : `Split' unexpected

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)
Discussion started by: Herry
2 Replies

2. AIX

nim mksysb error :/usr/bin/savevg[33]: 1016,07: syntax error

-------------------------------------------------------------------------------- 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)
Discussion started by: astjen
9 Replies

3. Solaris

please review this cron syntax

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)
Discussion started by: jenovaux
2 Replies

4. Shell Programming and Scripting

(standard_in) 1: parse error

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)
Discussion started by: sparks
4 Replies

5. Shell Programming and Scripting

bc giving error: (standard_in) 2: parse error

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)
Discussion started by: manishma71
9 Replies

6. Shell Programming and Scripting

(standard_in) 1: parse error

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)
Discussion started by: jamie_123
5 Replies

7. Shell Programming and Scripting

IF section problem. syntax error: unexpected end of file error

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)
Discussion started by: jedzio
10 Replies

8. Shell Programming and Scripting

Standard_in error

# echo '6.5 < 2.7 ' |bc 0 # echo '4.8.5 > 4.8.4' |bc (standard_in) 1: syntax error (standard_in) 1: syntax error ---------------------------------------------------------- FILESET_A_VER_CHK2=4.8.5 FILESET_R_NAME_CHK2=4.8.5 if ] ; then ## echo "Fileset is higher " ... (2 Replies)
Discussion started by: Mathew_paul
2 Replies

9. UNIX for Advanced & Expert Users

Command syntax error in cron

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)
Discussion started by: migurus
2 Replies
All times are GMT -4. The time now is 08:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy