can't read the code.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting can't read the code.
# 1  
Old 07-22-2011
can't read the code.

Hi All,

I'm a newbie here, can you help me tried to figure out this code. i know that this code is to check the path directory, however when i tried to run the scripts it always says error even though the folder is exist.

Code:
CHECK_PATH_FXN()
{
_CHECK_PATH=$1
if [ ! -d "${_CHECK_PATH}" ]
then
${ECHO_CMD} "ERROR : ${_CHECK_PATH} path is not existing!"
sleep 5
exit
fi
}

Please advise,
Thanks
# 2  
Old 07-22-2011
Code:
 
CHECK_PATH_FXN()
{
_CHECK_PATH=$1
if [ ! -d "${_CHECK_PATH}" ]
then
${ECHO_CMD} "ERROR : ${_CHECK_PATH} path is not existing!"
sleep 5
exit
fi
}

Note : you have ! symbol in the if condition.
# 3  
Old 07-22-2011
Hi Sir,

it says ERROR : path is not existing! even though the path is exist.

Code:
PRODUCT_SCRIPT_NAME=`${BASENAME_CMD} $0`
PRODUCT_NAME_CONV=`${BASENAME_CMD} $0 | ${AWK_CMD} -F".sh" '{print $1}'`
INPUT_PARAM="$1"

CHECK_PATH_FXN()
{
_CHECK_PATH=$1
if [ ! -d "${_CHECK_PATH}" ]
then
${ECHO_CMD} "ERROR : ${_CHECK_PATH} path is not existing!"
sleep 5
exit
fi
}

i don't know if there's something wrong in the $1 which is the input param.

Please advise
Thanks
# 4  
Old 07-22-2011
-d "${_CHECK_PATH}" ----> will return zero (0), if the directory is there
! --- makes the statement as true. ( because 0 is false and other numbers are true in if condition)

just check like this, in the terminal

Code:
 
[ -d /tmp ] && echo $?    # will return zero

Code:
 
[ 0 ] && echo  "if condition" || echo "else condition"
[ 1 ] && echo  "if condition" || echo "else condition"

# 5  
Old 07-22-2011
thank you very much sir, i'm going to try this.

Thanks,
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How is html code read, compared to say python?

so, the first line of bash, perl, python, ruby, and similar languages must contain the path to the interpreter...i.e. #!/bin/perl, or #!/bin/python. so in the case of a perl script, for instance, a perl script cannot and will never run if the perl program is not installed/present on the system. ... (9 Replies)
Discussion started by: SkySmart
9 Replies

2. Programming

C Code to read a word from file

Hello All, I have to write a C Code to read a word from file and Keep track of the number of word occurrence in each line and total in the file. Maintaining total count is easier but maintaining per line count is what I am struggling to achieve. I thought of maintaining linked list... (3 Replies)
Discussion started by: anand.shah
3 Replies

3. Shell Programming and Scripting

Read files in shell script code and run a C program on those files

HI, I am trying to implement a simple shell script program that does not make use of ls or find commands as they are quite expensive on very large sets of files. So, I am trying to generate the file list myself. What I am trying to do is this: 1. Generate a file name using shell script, for... (2 Replies)
Discussion started by: shoaibjameel123
2 Replies

4. UNIX for Advanced & Expert Users

Returning exit code from a while read $inputline

Hi searched hi and wide for this with no luck. Maintaining a bash script that #!/usr/bin/bash #does some stuff like setting env etc. f_do_dbwork ... .. #Now I want to exit with the value of $err however $err is re-initialised to 0 on exiting the function Always 0 .... ... (3 Replies)
Discussion started by: StevePr
3 Replies

5. Shell Programming and Scripting

return code of read and/or for

I am trying to validate an ip address, based on what is in the netmasks file, I have a function that checks the values of the ip against the network and netmask, this returns a 1 if the ip doesn't match and a 0 if the IP does. ##################### #Validate IP Network#... (1 Reply)
Discussion started by: eeisken
1 Replies

6. Shell Programming and Scripting

shell code to read and extract a file

how can i check for an unix data structure (1 Reply)
Discussion started by: jhuapaya
1 Replies

7. Shell Programming and Scripting

isql can't read code

Hi Guys, I'm a newbie here can you please help me reading this code. because i'm confuse. select b.field_value, b.cust_ac_no, b.net_svc_id, b.inst_seq_no, b.field_id, b.comp_status, b.inst_status, b.inststdt into bash_temp -- is this... (3 Replies)
Discussion started by: nikki1200
3 Replies

8. UNIX for Dummies Questions & Answers

Any tips/suggestions for a newbie beginning to read the Linux Kernel Source Code

Hi All, I recently downloaded the Linux kernel source code, added them all to a project in MS VC++ and plan to read through it so that I can improve the way I code, read/understand a large code database and hopefully contribute something to the development of the Linux OS. I have taken a... (3 Replies)
Discussion started by: clavian
3 Replies
Login or Register to Ask a Question