Standard_in error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Standard_in error
# 1  
Old 07-13-2017
Standard_in error

Code:
# 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

----------------------------------------------------------
Code:
FILESET_A_VER_CHK2=4.8.5
FILESET_R_NAME_CHK2=4.8.5

if [[ `echo "$FILESET_A_VER_CHK2 > $FILESET_R_NAME_CHK2" |bc` -eq 1 ]] ; then
##      echo "Fileset is higher "
      STATUS="VALID"
      CHK1=N
   else
      if [[ `echo "$FILESET_A_VER_CHK2 < $FILESET_R_NAME_CHK2" |bc` -eq 1 ]] ; then
##         echo "Fileset is lower "
          STATUS="INVALID"
          CHK1=N
       else
          CHK2=N
      fi
    fi

--------------------------

Code:
+ FILESET_A_VER_CHK2=4.8.5
+ FILESET_R_NAME_CHK2=4.8.5
++ echo '4.8.5 > 4.8.5'
++ bc
(standard_in) 1: syntax error
(standard_in) 1: syntax error
+ [[ '' -eq 1 ]]
++ echo '4.8.5 < 4.8.5'
++ bc
(standard_in) 1: syntax error
(standard_in) 1: syntax error
+ [[ '' -eq 1 ]]
+ CHK2=N


Last edited by jim mcnamara; 07-13-2017 at 05:09 PM..
# 2  
Old 07-13-2017
This is not a clear question, just bc syntax errors. bc gives kind of ancient looking errors back from tty days.

4.8.5 is not a number - not floating point, not an integer.

That series of numbers has to be compared as a string:
Code:
$ a=1.2.3
$ b=1.2.3.0
$ [ "$a" = "$b" ]  || echo 'not equal'
not equal
$ b="1.2.3"
$ [ "$a" = "$b" ] && echo 'equal'
equal

# 3  
Old 07-13-2017
Code:
##

function ver_comp
{
   cat - | awk ' {
     c1=split($1,a,".");
     m=c1
     c2=split($2,b,".");
     (c2 > m) ? (m=c2): 0;
     for (i=1; i<=m; i++) v1=v1 sprintf("%05s", a[i]);
     for (i=1; i<=m; i++) v2=v2 sprintf("%05s", b[i]);

     if  (v1 == v2) r="=";
     if  (v1 > v2) r=">";
     if  (v1 < v2) r="<";
     print r;
   }'
}

FILESET_A_VER_CHK2=4.8.6
FILESET_R_NAME_CHK2=4.8.6

cmp=`echo "$FILESET_A_VER_CHK2" "$FILESET_R_NAME_CHK2"|ver_comp`

echo "$FILESET_A_VER_CHK2 $cmp $FILESET_R_NAME_CHK2"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Print Error in Console and both Error & Output in Log file - UNIX

I am writing a shell script with 2 run time arguments. During the execution if i got any error, then it needs to redirected to a error file and in console. Also both error and output to be redirected to a log file. But i am facing the below error. #! /bin/sh errExit () { errMsg=`cat... (1 Reply)
Discussion started by: sarathy_a35
1 Replies

2. Shell Programming and Scripting

(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. ... (7 Replies)
Discussion started by: SysAdminRialto
7 Replies

3. 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

4. Solaris

Rpcinfo: can't contact portmapper: RPC: Authentication error; why = Failed (unspecified error)

I have two servers with a fresh install of Solaris 11, and having problems when doing rpcinfo between them. There is no firewall involved, so everything should theoretically be getting through. Does anyone have any ideas? I did a lot of Google searches, and haven't found a working solution yet. ... (2 Replies)
Discussion started by: christr
2 Replies

5. UNIX for Dummies Questions & Answers

> 5 ")syntax error: operand expected (error token is " error

im kinda new to shell scripting so i need some help i try to run this script and get the error code > 5 ")syntax error: operand expected (error token is " the code for the script is #!/bin/sh # # script to see if the given value is correct # # Define errors ER_AF=86 # Var is... (4 Replies)
Discussion started by: metal005
4 Replies

6. 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

7. 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

8. 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

9. 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

10. UNIX for Dummies Questions & Answers

Error: Internal system error: Unable to initialize standard output file

Hey guys, need some help. Running AIX Version 5.2 and one of our cron jobs is writing errors to a log file. Any ideas on the following error message. Error: Internal system error: Unable to initialize standard output file I'm guessing more info might be needed, so let me know. Thanks (2 Replies)
Discussion started by: firkus
2 Replies
Login or Register to Ask a Question