![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| whats wrong with this code | nadman123 | Shell Programming and Scripting | 4 | 04-15-2008 05:42 PM |
| tell me whats wrong with this | nadman123 | Shell Programming and Scripting | 1 | 04-14-2008 08:58 PM |
| tell me whats wrong in this? | nadman123 | Shell Programming and Scripting | 1 | 04-09-2008 10:11 PM |
| Whats wrong in this Script ??? | varungupta | UNIX for Advanced & Expert Users | 4 | 08-31-2007 01:02 AM |
| whats wrong with this awk??? | george_ | Shell Programming and Scripting | 5 | 04-04-2006 01:58 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
if [ -s $File ] ; Whats wrong in this ??
Code:
Subject="QM DOWN : Daily Monitoring Report " MAIL_RECIPIENTS="someone@some.where" dspmq > tempdspmq.txt.$$ cat tempdspmq.txt.$$ sed -n '/Running/p' tempdspmq.txt.$$ > temp cat temp if [ -s "$/clocal/mqbrkrs/user/mqsiadm/sanjay/temp" ] then echo "1 DONE" cat "$/clocal/mqbrkrs/user/mqsiadm/sanjay/temp" | mailx -s "$Subject" $MAIL_RECIPIENTS echo "2 DONE" fi echo "3 DONE" Whats wrong in this script ? I think its not executing the if [ ] statement. NOTE: you can replace any other command with 'dspmq' that i have written in my script. Please help ASAP. Last edited by vino; 08-20-2007 at 12:48 AM. Reason: Edited email address and added code tags |
| Forum Sponsor | ||
|
|
|
|||
|
what u mean by $/clocal/mqbrkrs/user/mqsiadm/sanjay/temp
I mean if temp is ur file name, why using "$"? the absolute path is enough. and if ur file exists in temp directory, use the absolue path inside the quotes. anchal |
|
|||
|
Another Q
thanks buddy.
if [ -s "/clocal/mqbrkrs/user/mqsiadm/sanjay/temp" ] Can you tell me the reason, why should not we put $ before the name of file, in such statements. ? In the cat command that i have used, its working in the same manner as you said. Why the $ is creating problem, even here i want contenty of temp file should be given to the pipe. cat "/clocal/mqbrkrs/user/mqsiadm/sanjay/temp" | mailx -s "$Subject" $MAIL_RECIPIENTS |
|
|||
|
Varun,
If you are using a variable and want to acces the value of the variable then only you need to put $ sign otherwise not needed. suppose path=/usr/bin/this if you are using this path variable in ur script then you have to put a $ sign before that to access the value. otherwise directly you can hardcode that value without the $ sign as you did in your if statement. Thanks Namish Last edited by namishtiwari; 08-20-2007 at 02:15 AM. |
|
|||
|
the cat command itself displays the content of the file...
"cat test" will display the file content of test. and using pipe u are redirecting the contents to the next command ( mail in ur case). for usage of $ follow the same rule as namishtiwari told. so just for example and considering ur case u define a variable like this file_path=/clocal/mqbrkrs/user/mqsiadm/sanjay/temp so in ur test command u need to use the value of the variable file_path which is the actual path of ur file. so u have to use "$file_path" so ur command 'll be like this if [ -s "$file_path" ] its always a good idea of using variables instead of hardcoding the paths. for both security as well as reusing of the code. anchal |
|||
| Google UNIX.COM |
| Thread Tools | |
| Display Modes | |
|
|