09-24-2008
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
zsh 4.3.4% cat file
ACFCFACCACARCSHFARCVJVASTVAJFTVAJVGHBAJ
zsh 4.3.4% cat file1
A
C
F
R
zsh 4.3.4% <file1 while read;do printf "%s=%d\n" "$REPLY" "${#$(<file)//}";done
A=9
C=7
F=4
R=2
That was the previous post.
But , can anybody can explain me in detail about this line
zsh... (2 Replies)
Discussion started by: dummy_needhelp
2 Replies
2. Shell Programming and Scripting
I did not understand what is ${0##/}
PGM=${0##/}
TMP=/tmp/${PGM}.$$
Please explain me. (2 Replies)
Discussion started by: gadege
2 Replies
3. Shell Programming and Scripting
could u please convert the below statement to shell script
----------
logdir=/smp/dyn/logfiles/cpm/pgm/pgIm
$logdir = $logdir ."/pgIm${toDate}*";
----
could u please explain the below clearly
grep -i adding $logdir | grep -iv equation | awk '{print \$NF}' | sort -u | sed -e... (1 Reply)
Discussion started by: mail2sant
1 Replies
4. AIX
this is the mksys b script....
can anyone explain .. what # and 1 in if condition
this is the first line of the script... it is not from middle of the script....
if
then
echo "Not enough parameters, need a client name for mksysb"
Usage="Usage: $0 <client name>"
... (2 Replies)
Discussion started by: honeym210
2 Replies
5. Shell Programming and Scripting
hi all i have an example i want one help me to understand cause i tried to test it but almost fail and i don't know how can i solve this problem " the main idea to read from two files and replace something from one to another " but i don't understand why it fail all time
$ cat main.txt... (4 Replies)
Discussion started by: maxim42
4 Replies
6. Homework & Coursework Questions
1. The problem statement, all variables and given/known data:
I have a retake assignment to complete for my computer networks and OS class. This isn't really my area, had I known last year I could have swapped it for a different module I would have done so. I'm determined to get through it... (6 Replies)
Discussion started by: Squall Moogle
6 Replies
7. Shell Programming and Scripting
I'm trying to follow a script and I see it begins with this:
if ; then
if ; then
print "blah $0 blah blah "
exit
fi
fi
What does $# mean? I found out that $1 refers to the shell environment and the last argument that was entered or passed in the previous command. I couldn't find $#... (2 Replies)
Discussion started by: MaindotC
2 Replies
8. Shell Programming and Scripting
why the case 2 will happen ? , ' should stop the history substitution ,shouldn't it?
case 1
# echo "123"|sed '/123/!d'
123
case 2
# echo "123
> 456
> 1
> "|sed '/123/!d'
-bash: !d': event not found
case 3
# echo "123
> 456
> 12
> "|sed '/123/'\!d
123
# bash --version (1 Reply)
Discussion started by: justlooks
1 Replies
9. Shell Programming and Scripting
Can someone do me a favour and explain the following for me:
((r=$RANDOM%$n+1))
I know what $RANDOM does but what is % sign and what does it do with %$n+1? (2 Replies)
Discussion started by: bashily
2 Replies
10. UNIX for Dummies Questions & Answers
Hi friends! I'm learning UNIX and I have a small question. Working with Shell, i put the name of one executable (in c language) + one number and it says this:
$ gcc misterioso_4.c
$ ./misterioso_4 6
got: ,
I can not find an answer in the manual because I havent applied any variable.... (5 Replies)
Discussion started by: dakota
5 Replies
LEARN ABOUT PHP
json_last_error
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)