Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
The ampersand makes a background job. The script will start all three scripts and return immediately. Caution: None of the scripts should need the results/effects of the other scripts, and they shouldn't write to the same file, otherwise you have a "race condition", which is virtually always a bad thing. If script1.sh must not run until script0.sh has run, e.g., because script0.sh mounts /filesrv and script1.sh uses that filesystem, they must be run sequentially, e.g.,
Code:
script0.sh
script1.sh
You could put an ampersand after script1.sh, so it gets started in the background (but still after script0.sh completes).
P.S.: You won't have job control for background jobs started in the script. They will be jobs of the subshell that executes the scripts, and when the script completes and the subshell exists, they orphan, and init adopts them.
Job control only works for jobs started by your (interactive) shell. If that's a problem, you could source the script instead of executing it.
Potential problems:
* If it's not in your path or PATH, you must specify a path, absolute or relative. E.g., these days most people don't have "." (the current directory) in their path any more as it's considered unsafe. Hence even if automnt.sh is in your home directory, "automnt.sh" won't be found. But "./automnt.sh" will.
* If you implemented it with xterms, you are dependent on X11 being available. (If your manager made you do it, blame it on him :-) ) This can fail for many reasons. E.g., if your machine is booted into runlevel 3 (by default, or just one fine day), you log in on a text interface, and there's no X. If you log in on a virtual terminal, to which you switch by pressing C-M-F1 (hold Ctrl and Alt, and push F1) etc, you don't have X either. When you log in remotely using ssh -x, X won't be forwarded (conversely ssh -X explicitly requests X forwarding). In all those circumstances, xterm will complain it cannot open dislay, and exit.
* If the script doesn't complete immediately, it makes you wait when you log in before you get a prompt. If you followed what you sketched above and started all subordinate scripts in parallel, you're fine. Otherwise you can run the script in the background. E.g., if it's in ~/script, put "script/automnt.sh &" into your profile.
* If you log in several times into the same machine, the script may run when it shouldn't. E.g., mount will fail (with a harmless warning) if the volume is already mounted.
* Regarding the name, note that "automounter" is a well-established concept. As I sketched earlier, it's something different.
No, I don't want you to change the "noauto" option in fstab. I'm just alerting you that the name you chose for your script may confuse others, because an automounter is a different thing.
If you have X defaults, the file is in your home directory and ends with an "s". Mine, for an example, is pretty short:
I would like to change the colors to my X terminals. I Know You don't like the X terminals. All the time I am asking about X terminals. I created the Xdefaults file.
I like xterm. I use them all the time. But relying on X windows in a situation like mounting a filesystem makes for a script that's less robust than necessary.
You say you created the Xdefaults file (note that it should start with a period). Does it do what you want?
Tell us more about changing "colors to" your X terminals. There are many ways in which you can change colors, starting with
Quote:
-cr color
This option specifies the color to use for text cursor.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.