Sponsored Content
Top Forums Shell Programming and Scripting parsing error in if statement Post 302137388 by porter on Monday 24th of September 2007 05:31:52 PM
Old 09-24-2007
Quote:
Originally Posted by rakeshou
hello,

I am trying to parse an error returned by a command inside the if statement but it is just displays the full error instead and then stops.


the above code just displays



please let me know how can I parse the error message returned by a command inside the if statement.

Thanks
Your back quotes just turn the output of the command into a string.

Try

Code:
pkginfo xxx | grep "was not found"

if test "$?" = "0" ; then
echo "no such package"
else
echo "similar version found will use pkgrm"
fi

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

xml parsing error in perl

******************PERL VERSION************************ This is perl, v5.8.1 built for i386-linux-thread-multi ERROR!!!!---Undefined subroutine &main::start called at /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/XML/Parser/Expat.pm line 469. *********************PERL... (1 Reply)
Discussion started by: bishweshwar
1 Replies

2. Shell Programming and Scripting

(sed) parsing insert statement column that crosses multiple lines

I have a file with a set of insert statements some of which have a single column value that crosses multiple lines causing the statement to fail in sql*plue. Can someone help me with a sed script to replace the new lines with chr(10)? here is an example: insert into mytable(id, field1, field2)... (3 Replies)
Discussion started by: jjordan
3 Replies

3. Shell Programming and Scripting

Error with if statement..Please help

:b:hi, I have a script as given below: pr_det="1" if then awk ' BEGIN {printf("%23s","session")}' >> report.txt awk ' BEGIN {printf "\n"} ' >> report.txt else awk ' BEGIN {printf("%55s","file_dsc")} ' >> report.txt awk ' BEGIN {printf("%101s","no_recs")} '... (1 Reply)
Discussion started by: jisha
1 Replies

4. Linux

error in if statement

Hi , I am getting an error when I run the script for checking word "view" in a file . I am using if statement. like this if then VW_VAR=` cat $TN.${ecmdate}.sql1 | grep -i view | awk '{print $3}' | cut -d '.' -f2 ` echo " VW_$VW_VAR " sed -e... (16 Replies)
Discussion started by: capri_drm
16 Replies

5. Shell Programming and Scripting

Error in IF statement

HI i am getting error while executing the given statement for filename in `cat a/file.lst` do if then echo "Exit Code Description :File $filename - is missing in Input Directory" >a.log exit else count1=`awk 'END {print NR}' $filename` echo "$count1">>a.log count2=`awk 'END {print... (4 Replies)
Discussion started by: ravi214u
4 Replies

6. Shell Programming and Scripting

Sed parsing error

I'm having a problem with a sed script. A programmer needs to change columns 942,943,944 to blank spaces only where it has the number 999 in every line. I didn't have a copy of the data file to test with originally so made my own up with a bunch of x's and put 999 in columns 5-7. The sed... (1 Reply)
Discussion started by: gravy26
1 Replies

7. UNIX for Dummies Questions & Answers

error in if statement

Hi, This is my script to catch any oracle errors. In this, the $sqlerr returns ORA-01017: invalid username/password; logon denied when i specify wrong username/password the if condition is failing. how can i resolve the issue. the if statement gives error sqloutput=`sqlplus -s -L... (1 Reply)
Discussion started by: Swapna173
1 Replies

8. AIX

parsing error when I run RSYNC

This is what I get when I run the RSYNC command. I just created brand new ssh2 rsa keys. warning: /come/out/and/play/.ssh2/id_rsa_2048_a: 4: parsing line failed. warning: /come/out/and/play/.ssh2/id_rsa_2048_a: 5: parsing line failed. warning: " " " " " " " " ... (3 Replies)
Discussion started by: tfort73
3 Replies

9. Shell Programming and Scripting

Error in if statement

I am working on script for stale nfs. the file consists of cat data01stale.log - - - - /abcd/backup - - - - /abcd/data Script (16 Replies)
Discussion started by: nareshkumar522
16 Replies

10. Shell Programming and Scripting

Parsing a PATH statement

I have a script that will be placing a trigger file for other applications. The user-inputted path is similar to: "/data/region/NorthAm/Project HAV 8H" The project path will not change throughout the script. However, pwd changes as the scanning continues in the script. I need to truncate... (3 Replies)
Discussion started by: leepet
3 Replies
DATEFMT_IS_LENIENT(3)							 1						     DATEFMT_IS_LENIENT(3)

IntlDateFormatter::isLenient - Get the lenient used for the IntlDateFormatter

	Object oriented style

SYNOPSIS
public bool IntlDateFormatter::isLenient (void ) DESCRIPTION
Procedural style bool datefmt_is_lenient (IntlDateFormatter $fmt) Check if the parser is strict or lenient in interpreting inputs that do not match the pattern exactly. PARAMETERS
o $fmt - The formatter resource. RETURN VALUES
TRUE if parser is lenient, FALSE if parser is strict. By default the parser is lenient. EXAMPLES
Example #1 datefmt_is_lenient(3) example <?php $fmt = datefmt_create( 'en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/Los_Angeles', IntlDateFormatter::GREGORIAN, 'dd/mm/yyyy' ); echo 'lenient of the formatter is : '; if ($fmt->isLenient()) { echo 'TRUE'; } else { echo 'FALSE'; } datefmt_parse($fmt, '35/13/1971'); echo " Trying to do parse('35/13/1971'). Result is : " . datefmt_parse($fmt, '35/13/1971'); if (intl_get_error_code() != 0) { echo " Error_msg is : " . intl_get_error_message(); echo " Error_code is : " . intl_get_error_code(); } datefmt_set_lenient($fmt,false); echo 'Now lenient of the formatter is : '; if ($fmt->isLenient()) { echo 'TRUE'; } else { echo 'FALSE'; } datefmt_parse($fmt, '35/13/1971'); echo " Trying to do parse('35/13/1971').Result is : " . datefmt_parse($fmt, '35/13/1971'); if (intl_get_error_code() != 0) { echo " Error_msg is : " . intl_get_error_message(); echo " Error_code is : " . intl_get_error_code(); } ?> Example #2 OO example <?php $fmt = new IntlDateFormatter( 'en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/Los_Angeles', IntlDateFormatter::GREGORIAN, "dd/mm/yyyy" ); echo "lenient of the formatter is : "; if ($fmt->isLenient()) { echo 'TRUE'; } else { echo 'FALSE'; } $fmt->parse('35/13/1971'); echo " Trying to do parse('35/13/1971'). Result is : " . $fmt->parse('35/13/1971'); if (intl_get_error_code() != 0){ echo " Error_msg is : " . intl_get_error_message(); echo " Error_code is : " . intl_get_error_code(); } $fmt->setLenient(FALSE); echo 'Now lenient of the formatter is : '; if ($fmt->isLenient()) { echo 'TRUE'; } else { echo 'FALSE'; } $fmt->parse('35/13/1971'); echo " Trying to do parse('35/13/1971'). Result is : " . $fmt->parse('35/13/1971'); if (intl_get_error_code() != 0) { echo " Error_msg is : " . intl_get_error_message(); echo " Error_code is : " . intl_get_error_code(); } ?> The above example will output: lenient of the formatter is : TRUE Trying to do parse('35/13/1971'). Result is : -2147483 Now lenient of the formatter is : FALSE Trying to do parse('35/13/1971'). Result is : Error_msg is : Date parsing failed: U_PARSE_ERROR Error_code is : 9 SEE ALSO
datefmt_set_lenient(3), datefmt_create(3). PHP Documentation Group DATEFMT_IS_LENIENT(3)
All times are GMT -4. The time now is 01:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy