8 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
tail -n +7 1.txt |head -n -2|awk '{print "sql", $1,"-c groom table " $5 ,"versions"}'
sql DB1 -c groom table T1 versions
sql DB2 -c groom table T2 versions
sql DB3 -c groom table T3 versions
but i want out should be
sql DB1 -c "groom table T1 versions"
sql DB2 -c "groom table T2... (3 Replies)
Discussion started by: rocking77
3 Replies
2. Shell Programming and Scripting
Hey guys, my first post on UNIX Forums(much overdue IMO)!
I've got this bit of code that doesn't seem to be working correctly for an Android app I'm working on:
"screen -S gmod1 -p 0 -X stuff " & "" & command.text & "`echo -ne '\015'`"""
Basically it types command.text(variable determined... (4 Replies)
Discussion started by: stingwraith
4 Replies
3. Shell Programming and Scripting
I have a csv file with 3 columns. Fields are comma delimited and strings are enclosed with quotation marks "". About 40% of the time, the line of values will start a new line thanks to carriage return characters within a string.
Example:
"apple","banana","orange"
"pineapple","grape","straw... (6 Replies)
Discussion started by: koeji
6 Replies
4. Shell Programming and Scripting
I need help extracting a column in a file separated by quotations. I would like to extract the first column of data and write it to a flat text file. EXAMPLE of data:
"c6e181396a1100ba19c53a6757a845c4","2012-05-18","email"
"70879000563753bb9051b4ab8df43ac4","2012-05-18","email"... (5 Replies)
Discussion started by: nickytcom
5 Replies
5. Shell Programming and Scripting
I have the following string:
31-01-2012, 09:42:37;OK;94727132638;"Mozilla/5.0 (Linux; U; Android 2.2.1)";3G;WAP;I need a script which is counting the occurrence of semicolons ( ; ) but exclude the ones from the quotation marks.
In the string given as example there are 8 semicolons but the script... (3 Replies)
Discussion started by: calinlicj
3 Replies
6. UNIX for Advanced & Expert Users
Hi colleagues,
I am development a script.
this flat file pp.txt contain this tree lines.
prueba
prueba1
prueba2
cat pp.txt |awk '{print a}' |while read a
do
var=`db2 select count(*) from $a`"
echo $var
done
executing var show me error.
I need var contain: db2... (1 Reply)
Discussion started by: systemoper
1 Replies
7. UNIX for Dummies Questions & Answers
Hi,
I am at a point in my script where I defined the number of the command line parameter I would like to set a variable equal to:
parameter_number=14
I would then like to set a variable equal to the correct parameter:
variable=$parameter_number
The issue here is that {} is required... (2 Replies)
Discussion started by: msb65
2 Replies
8. Shell Programming and Scripting
i have a file like this
aaaa bbbb cccc
aaa aaaa
aa cccccccccccccccc
aaaaaaa aaaa aaaa
i want to enclose this lines with double quotation:
"aaaa bbbb cccc"
"aaa aaaa"
"aa cccccccccccccccc"
"aaaaaaa aaaa aaaa"
any idea? (preferably without using sed)
thanks in advance... (3 Replies)
Discussion started by: gfhgfnhhn
3 Replies
JSON_LAST_ERROR(3) 1 JSON_LAST_ERROR(3)
json_last_error - Returns the last error occurred
SYNOPSIS
int json_last_error (void )
DESCRIPTION
Returns the last error (if any) occurred during the last JSON encoding/decoding.
PARAMETERS
This function has no parameters.
RETURN VALUES
Returns an integer, the value can be one of the following constants:
JSON error codes
+----------------------------+---------------------------------------------------+
| Constant | |
| | |
| | Meaning |
| | |
| | Availability |
| | |
+----------------------------+---------------------------------------------------+
| | |
| JSON_ERROR_NONE | |
| | |
| | No error has occurred |
| | |
| | |
| | T{ |
| | |
| | JSON_ERROR_DEPTH |
| | |
| | The maximum stack depth has been exceeded |
| | |
| | |
| | T{ |
| | |
| | JSON_ERROR_STATE_MISMATCH |
| | |
| | Invalid or malformed JSON |
| | |
| | |
| | T{ |
| | |
| | JSON_ERROR_CTRL_CHAR |
| | |
| | Control character error, possibly incorrectly |
| | encoded |
| | |
| | |
| | T{ |
| | |
| | JSON_ERROR_SYNTAX |
| | |
| | Syntax error |
| | |
| | |
| | T{ |
| | |
| | JSON_ERROR_UTF8 |
| | |
| | Malformed UTF-8 characters, possibly incorrectly |
| | encoded |
| | |
| | PHP 5.3.3 |
| | |
| | |
| JSON_ERROR_RECURSION | |
| | |
| | One or more recursive references in the value to |
| | be encoded |
| | |
| | PHP 5.5.0 |
| | |
| | |
| JSON_ERROR_INF_OR_NAN | |
| | |
| | One or more NAN or INF values in the value to be |
| | encoded |
| | |
| | PHP 5.5.0 |
| | |
| | |
|JSON_ERROR_UNSUPPORTED_TYPE | |
| | |
| | A value of a type that cannot be encoded was |
| | given |
| | |
| | PHP 5.5.0 |
| | |
+----------------------------+---------------------------------------------------+
EXAMPLES
Example #1
json_last_error(3) example
<?php
// A valid json string
$json[] = '{"Organization": "PHP Documentation Team"}';
// An invalid json string which will cause an syntax
// error, in this case we used ' instead of " for quotation
$json[] = "{'Organization': 'PHP Documentation Team'}";
foreach ($json as $string) {
echo 'Decoding: ' . $string;
json_decode($string);
switch (json_last_error()) {
case JSON_ERROR_NONE:
echo ' - No errors';
break;
case JSON_ERROR_DEPTH:
echo ' - Maximum stack depth exceeded';
break;
case JSON_ERROR_STATE_MISMATCH:
echo ' - Underflow or the modes mismatch';
break;
case JSON_ERROR_CTRL_CHAR:
echo ' - Unexpected control character found';
break;
case JSON_ERROR_SYNTAX:
echo ' - Syntax error, malformed JSON';
break;
case JSON_ERROR_UTF8:
echo ' - Malformed UTF-8 characters, possibly incorrectly encoded';
break;
default:
echo ' - Unknown error';
break;
}
echo PHP_EOL;
}
?>
The above example will output:
Decoding: {"Organization": "PHP Documentation Team"} - No errors
Decoding: {'Organization': 'PHP Documentation Team'} - Syntax error, malformed JSON
Example #2
json_last_error(3) with json_encode(3)
<?php
// An invalid UTF8 sequence
$text = "xB1x31";
$json = json_encode($text);
$error = json_last_error();
var_dump($json, $error === JSON_ERROR_UTF8);
?>
The above example will output:
string(4) "null"
bool(true)
SEE ALSO
json_last_error_msg(3), json_decode(3), json_encode(3).
PHP Documentation Group JSON_LAST_ERROR(3)