[opensuse] simple shell script "&&"
![](https://seccdn.libravatar.org/avatar/e164891e4d850a5cfd6a5765eb3965d0.jpg?s=120&d=mm&r=g)
Hello List, - how to get my script to update 'locate' database, after doing clamAV scan ? ................................. #!/bin/sh # # refresh clamAV datadase, next scan system with clamscan, then update 'locate' database # # freshclam && clamscan -ri / && updatedb .......................... - the final " && updatedb " seems not being executed : - Does "&&" mean "and" , or maybe "&&" means only execute IF stuff before is NOT done? ...................... thanks -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
![](https://seccdn.libravatar.org/avatar/b4047644c59f2d63b88e9464c02743fd.jpg?s=120&d=mm&r=g)
On 12/17/2013 11:31 AM, ellanios82 wrote:
Hello List,
- how to get my script to update 'locate' database, after doing clamAV scan ?
................................. #!/bin/sh # # refresh clamAV datadase, next scan system with clamscan, then update 'locate' database # # freshclam && clamscan -ri / && updatedb
..........................
- the final " && updatedb " seems not being executed :
- Does "&&" mean "and" , or maybe "&&" means only execute IF stuff before is NOT done?
......................
thanks
You are allowed more than one line in a shell script. (just sayin)... -- _____________________________________ ---This space for rent--- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
![](https://seccdn.libravatar.org/avatar/e164891e4d850a5cfd6a5765eb3965d0.jpg?s=120&d=mm&r=g)
On 12/17/2013 09:36 PM, John Andersen wrote:
On 12/17/2013 11:31 AM, ellanios82 wrote:
Hello List,
- how to get my script to update 'locate' database, after doing clamAV scan ?
................................. #!/bin/sh # # refresh clamAV datadase, next scan system with clamscan, then update 'locate' database # # freshclam && clamscan -ri / && updatedb
..........................
- the final " && updatedb " seems not being executed :
- Does "&&" mean "and" , or maybe "&&" means only execute IF stuff before is NOT done?
......................
thanks
You are allowed more than one line in a shell script. (just sayin)...
- thank you : will place " updatedb " on another line ................. regards -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
![](https://seccdn.libravatar.org/avatar/96218cdc8862979a27ef55e2d0c9d796.jpg?s=120&d=mm&r=g)
Am Dienstag, 17. Dezember 2013, 21:31:23 schrieb ellanios82:
- Does "&&" mean "and" , or maybe "&&" means only execute IF stuff before is NOT done?
From "info bash":
An AND list has the form COMMAND1 && COMMAND2 COMMAND2 is executed if, and only if, COMMAND1 returns an exit status of zero. An OR list has the form COMMAND1 || COMMAND2 COMMAND2 is executed if, and only if, COMMAND1 returns a non-zero exit status. The return status of AND and OR lists is the exit status of the last command executed in the list. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
![](https://seccdn.libravatar.org/avatar/5ceab27a0ac5bd16e35fe0d5554b212a.jpg?s=120&d=mm&r=g)
ellanios82 -- ...and then ellanios82 said... % % Hello List, Hiya! % % - how to get my script to update 'locate' database, after doing clamAV % scan ? % ... % freshclam && clamscan -ri / && updatedb [snip] First freshclam will run, no matter what. If freshclam exits with a 0 status, which generally means "everything went successfully", then clamscan will run; if it doesn't, then all stops and your script is done. If clamscan exits with a 0, then updatedb will run; if it doesn't, then all stops and your script is done. If updatedb exits with a 0, then your script will exit with a 0; if it doesn't (or if anything didn't before now), your script will exit with that same non-zero exit code. Since you report that updatedb is not running, I would start by checking on clamscan. You might rewrite this as if freshclam then echo "freshclam succeeded; moving on" >&2 if clamscan -ri / then echo "clamscan succeeded; moving on" >&2 if updatedb then echo "updatedb succeeded; we're done" >&2 else echo "updatedb exited with a $? status!" >&2 exit $? fi else echo "clamscan exited with a $? status!" >&2 exit $? fi else echo "freshclam exited with a $? status!" >&2 exit $? fi to verify each step. Season to taste :-) HTH & Happy Holidays :-D -- David T-G See http://justpickone.org/davidtg/email/ See http://justpickone.org/davidtg/tofu.txt
![](https://seccdn.libravatar.org/avatar/e164891e4d850a5cfd6a5765eb3965d0.jpg?s=120&d=mm&r=g)
On 12/17/2013 10:15 PM, David T-G wrote:
You might rewrite this as
if freshclam then echo "freshclam succeeded; moving on" >&2 if clamscan -ri / then echo "clamscan succeeded; moving on" >&2 if updatedb then echo "updatedb succeeded; we're done" >&2 else echo "updatedb exited with a $? status!" >&2 exit $? fi else echo "clamscan exited with a $? status!" >&2 exit $? fi else echo "freshclam exited with a $? status!" >&2 exit $? fi
to verify each step. Season to taste :-)
HTH & Happy Holidays
- thanks all , regards -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
![](https://seccdn.libravatar.org/avatar/27aacf61a13c66fcc083fcf8a84823bc.jpg?s=120&d=mm&r=g)
On 12/17/2013 01:31 PM, ellanios82 wrote:
freshclam && clamscan -ri / && updatedb
Means if freshclam; then if clamscan -ri /; then updatedb fi fi If either freshclam or clamscan exit with a *nonzero* exit code, updatedb will not be run. I suspect 'clamscan -ri /' rarely, if ever, exits with a 0 exit code. If you want it all on one line, why not: freshclam && { clamscan -ri /; updatedb; } That will do if freshclam; then clamscan -ri / updatedb fi -- David C. Rankin, J.D.,P.E. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
![](https://seccdn.libravatar.org/avatar/e164891e4d850a5cfd6a5765eb3965d0.jpg?s=120&d=mm&r=g)
On 12/17/2013 10:28 PM, David C. Rankin wrote:
On 12/17/2013 01:31 PM, ellanios82 wrote:
freshclam && clamscan -ri / && updatedb Means
if freshclam; then if clamscan -ri /; then updatedb fi fi
If either freshclam or clamscan exit with a *nonzero* exit code, updatedb will not be run.
I suspect 'clamscan -ri /' rarely, if ever, exits with a 0 exit code. If you want it all on one line, why not:
freshclam && { clamscan -ri /; updatedb; }
That will do
if freshclam; then clamscan -ri / updatedb fi __________________
- many thanks regards -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
![](https://seccdn.libravatar.org/avatar/b4047644c59f2d63b88e9464c02743fd.jpg?s=120&d=mm&r=g)
On 12/17/2013 12:28 PM, David C. Rankin wrote:
On 12/17/2013 01:31 PM, ellanios82 wrote:
freshclam && clamscan -ri / && updatedb
Means
if freshclam; then if clamscan -ri /; then updatedb fi fi
If either freshclam or clamscan exit with a *nonzero* exit code, updatedb will not be run.
I suspect 'clamscan -ri /' rarely, if ever, exits with a 0 exit code. If you want it all on one line, why not:
freshclam && { clamscan -ri /; updatedb; }
That will do
if freshclam; then clamscan -ri / updatedb fi
This is all well and good, but there is no logical reason to only run updatedb iff clamscan exits with any particular code. The idea that you would NOT need an updated locate database unless clamscan exited cleanly makes no sense. Like saying you only sharpen your pencil if (and only if) you found no mushy grapes in the fruit bowl. -- _____________________________________ ---This space for rent--- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
![](https://seccdn.libravatar.org/avatar/27aacf61a13c66fcc083fcf8a84823bc.jpg?s=120&d=mm&r=g)
On 12/17/2013 02:51 PM, John Andersen wrote:
The idea that you would NOT need an updated locate database unless clamscan exited cleanly makes no sense. Like saying you only sharpen your pencil if (and only if) you found no mushy grapes in the fruit bowl.
Mine is not to wonder why...... ROTFLMAO..... mushy grapes..... -- David C. Rankin, J.D.,P.E. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
participants (5)
-
David C. Rankin
-
David T-G
-
ellanios82
-
John Andersen
-
Markus Koßmann