ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
hi all im dipping toes into the shell scripting world and im already lost. i reading a book its upstairs at moment but im confused i thought shell scripting was all done in shell not in say anjuta for example? i am somewhat familar with C code but this has just lost me. i did create a file it told me to i think it was called "logins" and i only have 3 lines in it not really sure what im doing. i guess my question should be "how do i kno wwhen to put it in terminal or when to put it in program (kdevelop,anjuta).
If you are trying to run commands that would normally be run from the shell then you can easily put them into a bash script to be run over and over again. The first line of a bash script must start with;
#!/bin/bash
Anything after that will mostly be commands you can run from a bash prompt. After creating the file you also have to add the executable flag to the script file.
chmod +x filename
will do this for the user who created the script. Then if you want to run the script at set intervals you can have it run in cron or from a command promt type ./filename if you are in the directory holding the file and that directory is not in your path.
The only thing I'd add to the above, is that the #!/bin/bash is a good idea, but FYI, if you don't put it in, the system will use whatever shell is defined in the user's login entry in /etc/passwd.
On Linux this is usually /bin/bash
Hence, you won't always see it specified explicitly in other's code.
Thx ... also,
chmod +x filename.sh gives:
-rwxrwxr-x
perms.. not a good idea. Use
chmod u+x filename.sh
-rwxrw-r--
Ideally you prob want
-rwx------
ie
chmod u=rwx filename.sh
chmod g-rwx filename.sh
chmod o-rwx filename.sh
BTW, on commercial Unices, default shell is prob ksh (korn shell; similar to bash), csh (old) or sh (posix... bit like ksh).
There are several others avail ...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.