Hi,
I need to prompt for a response from a user to enter a path
read dest_dir?"Please Enter Directory :"
How do I do this until a valid directory is entered by the user. I can use
to check the existence of the directory. However when I try the following I cannot get it to work.
while ... (2 Replies)
I'm trying to write a script that identifies whether a directory of the form AWL.????????.IP exists. I have one that exists which is AWL.05301032.IP.
When I test like this: If ]
I get true, but when I test like this:
If ]
Or like this
If ]
Or any other variation of wild cards, I... (4 Replies)
Hi.
I what to write a make file that inside a target I want to check if a directory exists.
some like:
### make
a:
if ;then
<command 1>
else
<command 2>
fi
### make end
Thanks a lot
---------------------- (2 Replies)
Hello:
Can someone please help me figure out what is wrong here, my script does not move on to the "else" part even though there is no .ssh directory on my remote server:
$more putkey.sh
#!/bin/ksh
for server in `cat list`
do
if ; then
cat $HOME/.ssh/id_rsa.pub |ssh $server ' cat >>... (4 Replies)
Hey guys im trying to check if the directory exists
i get a syntax error on the elif statement iv tried using else and still same result im not sure. If the directory does not exist can i just insert mkdir /tmp/old under the elif once that part gets working
if ; then
#do nothing
elif
echo... (20 Replies)
cp $PATHLOGS/$DATE/*.* $TMP/logs_tmp/
cp $PATHLOGS/$DATE1/*.* $TMP/logs_tmp/
Before copying the files I have to check if the directory $DATE1 and $DATE2 exists.
If directory exists then, check if the folder contains some files.
if the file exists then, check if the file size is greater... (3 Replies)
I want to perform SQL *Loader operation only if a file named "load.txt" exists in a directory "/home/loc/etc". Please help how to check this with a if condition. (8 Replies)
Hi,
I am using solaris 10 OS and bash shell.just checking for small code snippet which follows below.
/export/home/vomappservers/spa/common/5.0
/export/home/vomappservers/spa/common/scripts
/export/home/vomappservers/spa/tools
/export/home/vomappservers/spa/scm5.0/SCCS... (5 Replies)
Hi Gurus,
I have a requests to find if all the file in the filelist exist in certain directory.
example:
my filelist
abc
def
ddd
cde
afg
how can I find these 5 files exists at director /home/abc
Thanks in advance (7 Replies)
Hi guys,
I am beginner trying to learn unix. So any help is welcomed.
My requirement is to check whether is a file exists in a particular directory or not.
The directory path and filename are taken dynamically with user interaction. So the program should continue only if the $filename... (1 Reply)
Discussion started by: maris_markur
1 Replies
LEARN ABOUT PHP
json_last_error
JSON_LAST_ERROR(3) 1 JSON_LAST_ERROR(3)json_last_error - Returns the last error occurredSYNOPSIS
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)