Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
O.K., I know there are several scripting langauges or shells out there, the two most prevailant seem to be bash and csh. I several questions about these two in particular.
1. Is there a link or source which does a quick, side by side comparison of these two?
2. What controls which shell becomes the default? Is it in .login? I boot to Gnome and use terminal to get a command prompt.
3. If you're running bash, then 'source" is needed to run a csh script, correct?
4. Is there a command which tells you which script is currently running?
5. Should it matter which shell is running if all my scripts have the !#/bin/bash or !#/bin/csh as their first line?
1) There are many online discussions -- the most common Csh Programming Considered Harmful. Which is a decent discussion on why using csh for programming is generally a bad idea. Note, I prefer tcsh as my main method of interaction but rarely use it for scripts unless the script is very basic and not going to leave my control.
2) /etc/passwd determines the default shell.
3) I have no idea what you're asking.
4) echo $SHELL; should tell you the current shell... this is not true in reality often enough to make me uncomfortable even suggesting it. Often changing shells does not change this.
5) It should not matter... your regular shell will not play a role as long as the first line points to a valid shell. Note, some systems do not correctly support this and will always use /bin/sh -- no modern system I know of has that limitation. It is also important to note that /bin/bash is not standard and will not work on most *nix operating systems outside linux. /bin/sh will always work but will not always point to bash.
Although it is fine to use bash if you want for your own stuff... it does effect portability and you should consider using plain bourne shell without bash syntax if possible. Just a word of advice from someone who spent a few years passing scripts from *BSD to Linux to Solaris.
You know, I just do very little actual Bash-shell scripting. I normally use Python. I know of others who swear by (or swear at)Perl. Still others use PHP for web-sites and also use it for other scripting tasks as well.
You can build entire applications, cross-platform ones at that, with Python tools like "Boa Constructor," which is extremely nice.
It is very nice to be able to "script things," although I find it very painstaking to do it in Bash-scripting. Given the plethora of other, better choices out there, I simply use one of those.
Note: The so-called "shebang" #! that you'll find at the start of any shell-script specifies the command-processor to be used. So you can write a command, and execute it, in any of these languages with no difference in how you invoke them.
I'd strongly encourage you to spend some time learning or at least looking-at all three of the languages I just mentioned. All of them, most likely, are already present on your computer.
My suggestion is look at all of them, but only really master one. If you do this you'll pick up the other two really easy, if you ever deciede you need the other two.
Those langauges sound great and I will learn them. I am getting into Linux for one reason, to use a specific weather analysis program called GEMPAK. GEMPAK requires that a set-up file called Gemenviron be run and I was given both a bash and csh version of this file.
I wrote scripts which make use of wget to retrieve the weather data for GEMPAK. They all work but I started running into problems putting them into crontab.
Another issue related to my last post: why when I invoke csh would a message pop up saying "(dir name/file): no such file or directory"? Is csh reading a set up file before it runs?
You sound alot like I was ceaseless. I needed to automate several of the things that I'm working on and with much help from this forum (Thank you all) I've learned quite a bit on scripting with bash. I am currently learning perl and because I have a good understanding of how bash is structured I'm having a much easier time learning it and it's making sense to me. I agree with posts above about learning one well and then trying another.
You've picked the right place for help... There are some amazingly sharp people here.
Another issue related to my last post: why when I invoke csh would a message pop up saying "(dir name/file): no such file or directory"? Is csh reading a set up file before it runs?
.login and .cshrc get read by csh when it starts.
Is that a literal error? Is this every time or with certain scripts? You can find that and fix it faily simply.
Everytime I type csh, "GEMPAK5.8.4/Gemenviron: No such directory or file" appears which leads me to believe something is incorrctly set in .login or .cshrc.
[gempak@vortex ~/GEMPAK5.8.4]$ grep GEMPAK ~/.cshrc ~/.login
/home/gempak/.cshrc:source /GEMPAK5.8.4/Gemenviron
grep: /home/gempak/.login: No such file or directory
# Gemenviron file for GEMPAK 5.8
#
# Sets environment variables used in running GEMPAK
# UNIDATA Program Center 6/1/92 (PB)
# Revised 8/31/94 for GEMPAK 5.2
# Modified 12/95 for Gempak5.2.1/Nawips (Chiz)
# Modified 8/96 for Gempak5.4/NAWIPS (Chiz)
# Modified 10/00 for Gempak5.6/NAWIPS (Chiz)
# Modified 3/04 for Gempak5.7/NAWIPS (Chiz)
#---------------------------------------------------------------------
# The command
# source Gemenviron
#
# or the individual lines below, must be included in your .login or
# .cshrc file!
#---------------------------------------------------------------------
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.