Solaris / OpenSolarisThis forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a question about using the ps within backqoutes (``)
When I tried to write a script which is supposed to run just once at a time
I encountered the following thing which I don't know if it's a BUG or FEATURE.
inside the script 'runonce.sh':
---begin script---
#! /bin/bash
# just run the ps and watch te output
ps -ef | grep 'runonce.sh'
actually the ps is not running twice at the same time. It gets started in consecutive.
Besides what I don't understand is why in $RESULT_FULL I'm getting the runonce.sh script twice ?
If I run the same script in KSH( just changing #!/bin/bash to #!/bin/ksh )
I'm geting the expected result of 1 script process and 1 grep process.
As you can see in BASH I'm getting 3 processes 2 scripts running and 1 grep.
Are you asking why you see "/bin/bash" and "grep" lines? The grep line is the result of your script. You might try the "grep -v grep" trick or grep for [r]unonce.sh.
My guess would be that bash is either forking or firing a thread that appears to have the same command name as itself (before being updated by the loader possibly).
In the meantime I found a workaround for this behavior.
I just thougt there would be no difference between ksh and bash concerning backquotes ( or at least I've never read anything about this ).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.