![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| gcd.sh script doesn't work... | kantze | Shell Programming and Scripting | 1 | 01-17-2008 09:46 PM |
| Modify Perl script to work with txt - Permissions script | joangopan | Shell Programming and Scripting | 1 | 09-12-2007 11:38 PM |
| Why does this script not work? Please help | duke0001 | Shell Programming and Scripting | 4 | 02-22-2007 09:28 PM |
| Script doesn't work, but commands inside work | cheongww | UNIX for Dummies Questions & Answers | 2 | 11-14-2006 10:52 PM |
| sed script. How does it work? | billy5 | Shell Programming and Scripting | 2 | 09-02-2005 04:45 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
My script does not work - could you pls help?
Hi all,
I put together a script that seems not working as I would like to and after spending hours to find the problem I decided to ask your help. The thing I am trying to do is call AWK command on the TRUE branch of if statement. Else branch should only print out a message to screen. This is the code I am using: ... for printer in "$@" ; do lpstat $printer|grep $printer |grep '-' >$TEMP_FILENAME grep '-' $TEMP_FILENAME status=$? if [[$status -eq 0]] ; then awk ' { here I do some stuff... } ' $TEMP_FILENAME else echo "No jobs in the printer queue $printer ..." fi done The result I got is not what I expect: printerjob1 user priority 0 Jun 27 08:26 printerjob2 user priority 0 Jun 28 13:38 ./prg.sh[103]: [[0: not found No jobs in the printer queue printername ... So for me it seems program executes somehow both branches of the IF statement. The line 103 where the problem is indicated is: if [[$status -eq 0]] ; then I could not solve it , so please recommend me what the problem might be... Thank you! BearCheese |
|
||||
|
Leave a space before $status and after 0
Code:
if [[ $status -eq 0 ]] ; then Code:
if grep -q '-' $TEMP_FILENAME ;then
awk '
{
here I do some stuff...
}
' $TEMP_FILENAME
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|