Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Standard_in error

Shell Programming and Scripting


Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 07-13-2017   -   Original Discussion by Mathew_paul
Mathew_paul Mathew_paul is offline
Registered User
 
Join Date: Dec 2014
Last Activity: 27 September 2017, 1:27 PM EDT
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
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..
Sponsored Links
    #2  
Old Unix and Linux 07-13-2017   -   Original Discussion by Mathew_paul
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 19 November 2017, 7:33 PM EST
Location: NM
Posts: 11,239
Thanks: 571
Thanked 1,116 Times in 1,030 Posts
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

Sponsored Links
    #3  
Old Unix and Linux 07-13-2017   -   Original Discussion by Mathew_paul
rdrtx1 rdrtx1 is offline
Registered User
 
Join Date: Sep 2012
Last Activity: 18 November 2017, 6:17 PM EST
Location: Houston, Texas, USA
Posts: 983
Thanks: 0
Thanked 338 Times in 319 Posts

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"

Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
(standard_in) 1: parse error jamie_123 Shell Programming and Scripting 5 02-18-2014 04:55 AM
Rpcinfo: can't contact portmapper: RPC: Authentication error; why = Failed (unspecified error) christr Solaris 2 06-18-2013 11:40 AM
> 5 ")syntax error: operand expected (error token is " error metal005 UNIX for Dummies Questions & Answers 4 05-09-2011 11:30 AM
bc giving error: (standard_in) 2: parse error manishma71 Shell Programming and Scripting 9 08-04-2010 06:21 AM
(standard_in) 1: parse error sparks Shell Programming and Scripting 4 07-14-2010 06:35 AM



All times are GMT -4. The time now is 01:17 PM.