Sponsored Content
Top Forums Shell Programming and Scripting if stmt argument expected error Post 302495091 by dba_frog on Wednesday 9th of February 2011 09:47:07 AM
Old 02-09-2011
Code:
CT=0
while read LINE
do
    # Check to see if the LINE is non-empty, and has a <td> tag in it.
    if [[ "$LINE" == *"<td>"* ]]
    then
       # Increase the TD counter by 1
       ((CT++))
     fi
done <test.htm

error: ksh: syntax error: `==' unexpected

Code:
CT=0
while read LINE
do
    # Check to see if the LINE is non-empty, and has a <td> tag in it.
    if [ "$LINE" == *"<td>"* ]
    then
       # Increase the TD counter by 1
       ((CT++))
     fi
done <test.htm

error: ksh[4]: ==: unknown test operator
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Facing test: argument expected ERROR

Hi All, When i run the below code : v_shortfield = "" if ; then echo "ravi" else echo "kumar" fi i am getting output as : sam.ksh: test: argument expected kumar Why i am getting error test:argument expected and why i am not getting output as "ravi" :confused: (5 Replies)
Discussion started by: rkrgarlapati
5 Replies

2. Shell Programming and Scripting

ERROR-> test: argument expected , what does it mean?

I am trying to compare two integer variables in the if statement, but i am getting this "test:argument expected". What am i missing? Why is the if loop not executing correctly? trunkPCM="100000"; more $FILE |while read line do PCM=`echo $line | awk '{ print $2 }'` ... (4 Replies)
Discussion started by: tan102938
4 Replies

3. Shell Programming and Scripting

test: argument expected

I'm newbie to coding script so i found test: argument expected when i run it. please help me a=`df -k |awk '{print $5 }'|egrep "(100%|%)"|cut -d"%" -f1|tail -1` if then df -k|egrep "(100%|%)"|awk '{print $1,$5,$6}' else echo "No disk capacity more than 80%" fi thk in advance (7 Replies)
Discussion started by: unitipon
7 Replies

4. UNIX for Dummies Questions & Answers

"test: argument expected" error

Hi, No need to say I'm new to unix shell scripting. I have a very simple script that goes this way: for datos in `ls -rt $UNXLOG/26-Jan*` do export arch=`echo $datos |cut -d, -f1` if then export linea1=`grep Debut ${arch}` export horatot=`echo $linea1 |cut -d' ' -f5` ... (7 Replies)
Discussion started by: mvalonso
7 Replies

5. Shell Programming and Scripting

test: argument expected

# to search a file if it exists and whether its readable or not # if yes print its first 5 lines echo enter the filename to be searched read fname if #-d $fname then echo file doesn exists elif then echo its a directory elif then cat $fname else echo its not readable fi # end of... (9 Replies)
Discussion started by: gotam
9 Replies

6. Shell Programming and Scripting

error : test: argument expected

Hello all, I am trying to figure out why i am getting an error while executing the script...altought it seems like its work...but still get the test arguement error...any help would be appericiate...this script basically connects to any oracle db ( just have to pass db name to it)... (4 Replies)
Discussion started by: abdul.irfan2
4 Replies

7. UNIX for Advanced & Expert Users

Error:--test: argument expected--Even though i give an argument.

Hi All, I am running the script VBoxManage list vms |sed 's/"//g' | cut -d " " -f1 > har1out.mytxt result=`cat har1out.mytxt | grep $1' echo $result echo $1 { if then echo pass else echo fail fi (2 Replies)
Discussion started by: harsha85
2 Replies

8. Shell Programming and Scripting

Error- test: argument expected

check_build_info_table() { if then export build_info_table=`sqlplus -s sna/dbmanager <<! set pagesize 0 heading off feedback off SELECT DISTINCT TABLE_NAME FROM ALL_TABLES WHERE OWNER = 'XYZ' AND TABLE_NAME = 'MY_TABLE'; exit !` ... (3 Replies)
Discussion started by: ambarginni
3 Replies

9. UNIX for Dummies Questions & Answers

Test: argument expected error in shell script

Hi, I am trying to write a small script that validates if there exist files that start with a pattern in a given directory. Below is the piece of my script: #!/usr/bin/ksh BTFDIR=/opt/ships/temp if then echo 'found' else echo 'not found' fi When I run this... (2 Replies)
Discussion started by: snvniranjanrao
2 Replies

10. Shell Programming and Scripting

Test: argument expected

The following example prompts are passed into the shell script. $1 = /tmp/dir/ $2 = varies (test.txt, test1.txt, test2.txt...) $3 = test_YYYYMMDD.txt --------------------------------------------------------------------------- #!/bin/sh cd $1 if ; then if ; then ... (3 Replies)
Discussion started by: smkremer
3 Replies
MYSQLI_STMT_AFFECTED_ROWS(3)						 1					      MYSQLI_STMT_AFFECTED_ROWS(3)

mysqli_stmt::$affected_rows - Returns the total number of rows changed, deleted, or inserted by the last executed statement

       Object oriented style

SYNOPSIS
int$mysqli_stmt->affected_rows () DESCRIPTION
Procedural style int mysqli_stmt_affected_rows (mysqli_stmt $stmt) Returns the number of rows affected by INSERT, UPDATE, or DELETE query. This function only works with queries which update a table. In order to get the number of rows from a SELECT query, use mysqli_stmt_num_rows(3) instead. PARAMETERS
o $ stmt -Procedural style only: A statement identifier returned by mysqli_stmt_init(3). RETURN VALUES
An integer greater than zero indicates the number of rows affected or retrieved. Zero indicates that no records where updated for an UPDATE/DELETE statement, no rows matched the WHERE clause in the query or that no query has yet been executed. -1 indicates that the query has returned an error. NULL indicates an invalid argument was supplied to the function. Note If the number of affected rows is greater than maximal PHP int value, the number of affected rows will be returned as a string value. EXAMPLES
Example #1 Object oriented style <?php $mysqli = new mysqli("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s ", mysqli_connect_error()); exit(); } /* create temp table */ $mysqli->query("CREATE TEMPORARY TABLE myCountry LIKE Country"); $query = "INSERT INTO myCountry SELECT * FROM Country WHERE Code LIKE ?"; /* prepare statement */ if ($stmt = $mysqli->prepare($query)) { /* Bind variable for placeholder */ $code = 'A%'; $stmt->bind_param("s", $code); /* execute statement */ $stmt->execute(); printf("rows inserted: %d ", $stmt->affected_rows); /* close statement */ $stmt->close(); } /* close connection */ $mysqli->close(); ?> Example #2 Procedural style <?php $link = mysqli_connect("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s ", mysqli_connect_error()); exit(); } /* create temp table */ mysqli_query($link, "CREATE TEMPORARY TABLE myCountry LIKE Country"); $query = "INSERT INTO myCountry SELECT * FROM Country WHERE Code LIKE ?"; /* prepare statement */ if ($stmt = mysqli_prepare($link, $query)) { /* Bind variable for placeholder */ $code = 'A%'; mysqli_stmt_bind_param($stmt, "s", $code); /* execute statement */ mysqli_stmt_execute($stmt); printf("rows inserted: %d ", mysqli_stmt_affected_rows($stmt)); /* close statement */ mysqli_stmt_close($stmt); } /* close connection */ mysqli_close($link); ?> The above examples will output: rows inserted: 17 SEE ALSO
mysqli_stmt_num_rows(3), mysqli_prepare(3). PHP Documentation Group MYSQLI_STMT_AFFECTED_ROWS(3)
All times are GMT -4. The time now is 06:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy