Sponsored Content
Top Forums UNIX for Dummies Questions & Answers if...elif...fi condition in Unix Post 27536 by Kelam_Magnus on Tuesday 3rd of September 2002 02:18:16 PM
Old 09-03-2002
I belive that = is usually only used for assigning a value to a variable in most programming languages.

Oombera is right for shell programming. You might need a - in front of those options like -eq, -ne, -gt, etc... .


BTW, the "test" structure that you are using can be used without the "if", if you are not using the if/elif/if/else structure. You can use the [ ] test statement by itself with the else statement. I might be wrong, I haven't used that in a long time. A bit fuzzy on the syntax.

test [ ]
<somecommand>...



My brain is your Brain...
Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If and Or Condition in Unix [ksh]

I have the code below. I want to said If TrackErrors > 0 or count == 0 then MailErrors else MailSuccess fi. if then MailErrors ${count} else MailSuccess ${count} fi Any helps greatly appreciated. (2 Replies)
Discussion started by: leemjesse
2 Replies

2. Shell Programming and Scripting

If..elif..else...fi

Hi all, I got some problems on executing the following scripts. Scripts: if ]; then echo "M${str}O 0 1" >> ${tempFile} elif ]; then echo "M${str}O 1 0" >> ${tempFile} else echo "M${str}O 0 0" >> ${tempFile} fi Error: "`;' is not expected." what's the problem? (2 Replies)
Discussion started by: Rock
2 Replies

3. Shell Programming and Scripting

Unix and db2 where condition issue(new line)

Hi I am extracting a column value(DESCRIPTION) from one table and passing it to another db2 statement in a shell code to fetch some value(ID) but the value when passed in where condition is taking as newline+value. Please find the out put when executed: + echo description is ::::... (1 Reply)
Discussion started by: msp2244
1 Replies

4. Shell Programming and Scripting

if condition to check the hostname (unix)

I want to know the if condition in checking the hostname in unix and then running a cron job (all in a single line) Thanks (2 Replies)
Discussion started by: prash358
2 Replies

5. Shell Programming and Scripting

how to use split command in unix shell with a condition

Hi all, I have a file which I want to split into several files based on a condition. This files has several records. I want one record per file. Each record ends with a //. So, I want to separate files based on this condition. I want split files to be named with the name across the field ID (for... (2 Replies)
Discussion started by: kaav06
2 Replies

6. Shell Programming and Scripting

Condition checking in UNIX

i have a script where i have to find the age of a file, if then echo "dnb file is present for the monthly load" >> $RUNLOG dnb="1" else echo "dnb file has not arrived yet" > $ERRLOG dnb="0" fi i know the file is available so... (3 Replies)
Discussion started by: lovelysethii
3 Replies

7. Shell Programming and Scripting

Checking for null condition in a UNIX variable

i have this code for i in `cat sql_output.txt` do -- some script commands done sql_output.txt has 1 column with employee_ids If the sql_output.txt is null then the do loop should not execute. How can i implement this. for i in `cat sql_output.txt` If i is null or empty then ... (5 Replies)
Discussion started by: rafa_fed2
5 Replies

8. Shell Programming and Scripting

If Condition Issue in UNIX

Hi I am trying to do a "IF" Condition in UNIX where we compare EACH file size in a directory with a SIZE (Parameter passed) If Each File size EXCEEDS parameter passed SIZE then we manipulate the file. Somehow the IF condition do not work ?? (is this Variable decalration issue ??) ... (9 Replies)
Discussion started by: Pete.kriya
9 Replies

9. UNIX for Advanced & Expert Users

How to create folder by using if and elif condition?

Hi All, I have already code to create folder for one country let say US , now we want to create folder/directory for JP country also using shell script , application server. $COUNTRY='US' if ] then if mkdir -m 777 -p /opt/TEST/$COUNTRY/$INVOICE >/dev/null 2>&1 | tee -a ... (5 Replies)
Discussion started by: Boost
5 Replies

10. Shell Programming and Scripting

Issue with condition "if then elif else fi"

Hi everybody, I must get trought a shell script 3 arguments. 1st argument = $1 (can take values REP1..4) 2nd argument = $2 (can take values A..Z) 3rd arguement = $3 (also can take values A...Z) I've written this code : #!/bin/bash if then liste=/data/folder1 echo... (6 Replies)
Discussion started by: shellX
6 Replies
MYSQLND_QC_GET_NORMALIZED_QUERY_TRACE_LOG(3)				 1			      MYSQLND_QC_GET_NORMALIZED_QUERY_TRACE_LOG(3)

mysqlnd_qc_get_normalized_query_trace_log - Returns a normalized query trace log for each query inspected by the query cache

SYNOPSIS
array mysqlnd_qc_get_normalized_query_trace_log (void ) DESCRIPTION
Returns a normalized query trace log for each query inspected by the query cache. The collection of the trace log is disabled by default. To collect the trace log you have to set the PHP configuration directive mysqlnd_qc.collect_normalized_query_trace to 1 Entries in the trace log are grouped by the normalized query statement. The normalized query statement is the query statement with all statement parameter values being replaced with a question mark. For example, the two statements SELECT id FROM test WHERE id = 1 and SELECT id FROM test WHERE id = 2 are normalized as SELECT id FROM test WHERE id = ?. Whenever a statement is inspected by the query cache which matches the normalized statement pattern, its statistics are grouped by the normalized statement string. PARAMETERS
This function has no parameters. RETURN VALUES
An array of query log. Every list entry contains the normalized query stringand further detail information. +---------------------+---------------------------------------------------+ | Key | | | | | | | Description | | | | +---------------------+---------------------------------------------------+ | | | | query | | | | | | | Normalized statement string. | | | | | | | | occurences | | | | | | | How many statements have matched the normalized | | | statement string in addition to the one which has | | | created the log entry. The value is zero if a | | | statement has been normalized, its normalized | | | representation has been added to the log but no | | | further queries inspected by PECL/mysqlnd_qc have | | | the same normalized statement string. | | | | | | | |eligible_for_caching | | | | | | | Whether the statement could be cached. An state- | | | ment eligible for caching has not necessarily | | | been cached. It not possible to tell for sure if | | | or how many cached statement have contributed to | | | the aggregated normalized statement log entry. | | | However, comparing the minimum and average run | | | time one can make an educated guess. | | | | | | | | avg_run_time | | | | | | | The average run time of all queries contributing | | | to the query log entry. The run time is the time | | | between sending the query statement to MySQL and | | | receiving an answer from MySQL. | | | | | | | | avg_store_time | | | | | | | The average store time of all queries contribut- | | | ing to the query log entry. The store time is the | | | time needed to fetch a statements result set from | | | the server to the client and, storing it on the | | | client. | | | | | | | | min_run_time | | | | | | | The minimum run time of all queries contributing | | | to the query log entry. | | | | | | | | min_store_time | | | | | | | The minimum store time of all queries contribut- | | | ing to the query log entry. | | | | | | | | max_run_time | | | | | | | The maximum run time of all queries contributing | | | to the query log entry. | | | | | | | | max_store_time | | | | | | | The maximum store time of all queries contribut- | | | ing to the query log entry. | | | | +---------------------+---------------------------------------------------+ EXAMPLES
Example #1 mysqlnd_qc_get_normalized_query_trace_log(3) example mysqlnd_qc.collect_normalized_query_trace=1 <?php /* Connect, create and populate test table */ $mysqli = new mysqli("host", "user", "password", "schema", "port", "socket"); $mysqli->query("DROP TABLE IF EXISTS test"); $mysqli->query("CREATE TABLE test(id INT)"); $mysqli->query("INSERT INTO test(id) VALUES(1), (2)"); /* not cached */ $res = $mysqli->query("SELECT id FROM test WHERE id = 1"); var_dump($res->fetch_assoc()); $res->free(); /* cache put */ $res = $mysqli->query("/*" . MYSQLND_QC_ENABLE_SWITCH . "*/" . "SELECT id FROM test WHERE id = 2"); var_dump($res->fetch_assoc()); $res->free(); /* cache hit */ $res = $mysqli->query("/*" . MYSQLND_QC_ENABLE_SWITCH . "*/" . "SELECT id FROM test WHERE id = 2"); var_dump($res->fetch_assoc()); $res->free(); var_dump(mysqlnd_qc_get_normalized_query_trace_log()); ?> The above examples will output: array(1) { ["id"]=> string(1) "1" } array(1) { ["id"]=> string(1) "2" } array(1) { ["id"]=> string(1) "2" } array(4) { [0]=> array(9) { ["query"]=> string(25) "DROP TABLE IF EXISTS test" ["occurences"]=> int(0) ["eligible_for_caching"]=> bool(false) ["avg_run_time"]=> int(0) ["min_run_time"]=> int(0) ["max_run_time"]=> int(0) ["avg_store_time"]=> int(0) ["min_store_time"]=> int(0) ["max_store_time"]=> int(0) } [1]=> array(9) { ["query"]=> string(27) "CREATE TABLE test (id INT )" ["occurences"]=> int(0) ["eligible_for_caching"]=> bool(false) ["avg_run_time"]=> int(0) ["min_run_time"]=> int(0) ["max_run_time"]=> int(0) ["avg_store_time"]=> int(0) ["min_store_time"]=> int(0) ["max_store_time"]=> int(0) } [2]=> array(9) { ["query"]=> string(40) "INSERT INTO test (id ) VALUES (? ), (? )" ["occurences"]=> int(0) ["eligible_for_caching"]=> bool(false) ["avg_run_time"]=> int(0) ["min_run_time"]=> int(0) ["max_run_time"]=> int(0) ["avg_store_time"]=> int(0) ["min_store_time"]=> int(0) ["max_store_time"]=> int(0) } [3]=> array(9) { ["query"]=> string(31) "SELECT id FROM test WHERE id =?" ["occurences"]=> int(2) ["eligible_for_caching"]=> bool(true) ["avg_run_time"]=> int(159) ["min_run_time"]=> int(12) ["max_run_time"]=> int(307) ["avg_store_time"]=> int(10) ["min_store_time"]=> int(8) ["max_store_time"]=> int(13) } } SEE ALSO
Runtime configuration, mysqlnd_qc.collect_normalized_query_trace, mysqlnd_qc.time_statistics, mysqlnd_qc_get_query_trace_log(3). PHP Documentation Group MYSQLND_QC_GET_NORMALIZED_QUERY_TRACE_LOG(3)
All times are GMT -4. The time now is 12:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy