Sponsored Content
Full Discussion: Error in IF statement
Top Forums Shell Programming and Scripting Error in IF statement Post 302214594 by methyl on Monday 14th of July 2008 10:44:29 AM
Old 07-14-2008
Syntax points taken into account.
The first "else" clause is not needed.
Also, the script exits on the first file missing from "a/file.lst". To continue looking at the list, replace "exit" with "continue".


for filename in `cat a/file.lst`
do

if [ ! -e $filename ]
then
echo "Exit Code Description :File $filename - is missing in Input Direc
tory" >a.log
exit
fi

count1=`awk 'END {print NR}' $filename`
echo "$count1">>a.log
count2=`awk 'END {print NR}' $a/$filename`
echo "$count2" >>a.log

if [[ $count1 == $count2 ]]
then
echo "Same $count2 -$filename is present in Input Directory" >>a.log
else
echo "different $count2 -$filename is present in Input Directory" >>a.lo
g
fi

done
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

parsing error in if statement

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. if ; then echo "no such package" else echo "similar version found will use pkgrm" fi the above code just displays please let me know... (2 Replies)
Discussion started by: rakeshou
2 Replies

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

3. Shell Programming and Scripting

Snytax error on If Statement--help

year=`date '+%Y'` month=`date '+%m'` day=`date '+%d'` day=`expr $day - 1` case $month in 1 | 3 | 5 | 7 | 8 | 10 | 12);; if($day =7 ); then $day=6 fi 4 | 6 | 9 | 11);; if ; then $day=31 fi 2);; if ; then if ; then (2 Replies)
Discussion started by: dannyd_y
2 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 insert statement

hi, When i try to run the code below, i get the following error "ksh: syntax error: `(' unexpected" i am not able to figure it out. Can anyone help me? Code: (2 Replies)
Discussion started by: ragavhere
2 Replies

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

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

8. Shell Programming and Scripting

If statement Syntax error

Hi Can you please tell me what is wrong with this line: if && ]; then basically i want to check if x = 12 and F (Filename) end with 'g'. But it is throwing syntax error. (7 Replies)
Discussion started by: rtagarra
7 Replies

9. Shell Programming and Scripting

Awk/if statement error

Can anybody tell the correct way to use the following awk pattern check within an if statement? When I run this command outside of the if statement cat /tmp/test2.out | awk -v T=$TIME -v G=$GROUP -v C=$CDATE '$0 ~ T && $0 ~ G && $0 ~ C' | grep -i "Starting the group" I get the following... (0 Replies)
Discussion started by: kieranfoley
0 Replies

10. UNIX for Beginners Questions & Answers

Error code with if statement

hello all im new to unix and when i use below script i get an error : #! /bin/bash Echo -e "enter the name of the file : \c" read file_name if then echo "$file_name found" else echo "$file_name not found" fi running the script i get below error : $ ./hello (26 Replies)
Discussion started by: Ibrahims1
26 Replies
MYSQLI_STMT_ERROR_LIST(3)						 1						 MYSQLI_STMT_ERROR_LIST(3)

mysqli_stmt::$error_list - Returns a list of errors from the last statement executed

       Object oriented style

SYNOPSIS
array$mysqli_stmt->error_list () DESCRIPTION
Procedural style array mysqli_stmt_error_list (mysqli_stmt $stmt) Returns an array of errors for the most recently invoked statement function that can succeed or fail. PARAMETERS
o $ stmt -Procedural style only: A statement identifier returned by mysqli_stmt_init(3). RETURN VALUES
A list of errors, each as an associative array containing the errno, error, and sqlstate. EXAMPLES
Example #1 Object oriented style <?php /* Open a connection */ $mysqli = new mysqli("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s ", mysqli_connect_error()); exit(); } $mysqli->query("CREATE TABLE myCountry LIKE Country"); $mysqli->query("INSERT INTO myCountry SELECT * FROM Country"); $query = "SELECT Name, Code FROM myCountry ORDER BY Name"; if ($stmt = $mysqli->prepare($query)) { /* drop table */ $mysqli->query("DROP TABLE myCountry"); /* execute query */ $stmt->execute(); echo "Error: "; print_r($stmt->error_list); /* close statement */ $stmt->close(); } /* close connection */ $mysqli->close(); ?> Example #2 Procedural style <?php /* Open a connection */ $link = mysqli_connect("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s ", mysqli_connect_error()); exit(); } mysqli_query($link, "CREATE TABLE myCountry LIKE Country"); mysqli_query($link, "INSERT INTO myCountry SELECT * FROM Country"); $query = "SELECT Name, Code FROM myCountry ORDER BY Name"; if ($stmt = mysqli_prepare($link, $query)) { /* drop table */ mysqli_query($link, "DROP TABLE myCountry"); /* execute query */ mysqli_stmt_execute($stmt); echo "Error: "; print_r(mysql_stmt_error_list($stmt)); /* close statement */ mysqli_stmt_close($stmt); } /* close connection */ mysqli_close($link); ?> The above examples will output: Array ( [0] => Array ( [errno] => 1146 [sqlstate] => 42S02 [error] => Table 'world.myCountry' doesn't exist ) ) SEE ALSO
mysqli_stmt_error(3), mysqli_stmt_errno(3), mysqli_stmt_sqlstate(3). PHP Documentation Group MYSQLI_STMT_ERROR_LIST(3)
All times are GMT -4. The time now is 02:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy