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.
I'm just starting to get used to linux. I've been using slackware for 2 weeks now. I do some programming in vB, but when I just need to write something really simple, I will write a batch file. So my question is can I write a program to run in the shell script without having to know C/C ++? Thanks in advance.
I don't understand the question. Bash is a shell (as are ksh, tcsh, and zsh) and a programming language of sorts. Shell scripts are like immeasurably more powerful batch files, yes. Go for it. Check out bash tutorials at the TLDP and various other things on the web and check out the bash man page (or shell of your choice).
-- Occurs to me to add: if you know any Linux commands at all, put a few in a text file that begins with
#!/bin/bash
The shebang (#!) declares it's a script to be interpreted by (in this case) bash. (You can also do #!/bin/less or #!/bin/awk -f or whatever.)
Then issue 'chmod 700 filename' and do
./filename
Voila. Script. (If the current directory is in your path or you save the file to a directory that is on your path you can just issue 'filename' without the './' You can also chmod it 7nn where n's anything you want - point is to make it executable for you at the very least.)
Then look into flow control - 'for...do...done', 'if...then...fi' and so on. Then go from there.
I think you understood what I meant. Sorry if it wasn't clear.
What I mean is in windows you can open notepad, write out some DOS commands, save it as a .bat and run it. I'll go research Bash and shell scripts. Thanks.
EDIT: Thanks for adding that extra info. That's exactly what i was trying to find out. What extension do I give to my script? Like how in win, it's .bat
Last edited by johnsmith1169; 05-16-2004 at 05:25 PM.
No, it was clear. Reading over it, I'm not sure what I didn't get myself. Sounded kind of like you were answering your own question, I guess - batch file=shell script. But, yeah, where to begin with them.
And welcome to Linux and LQ.
-- Oops. Missed the last edit. I don't give them any extension but convention is '.sh' if you do give them an extension. The executable bit is the key and the extension is arbitrary - different from DOS.
EDIT: Thanks for adding that extra info. That's exactly what i was trying to find out. What extension do I give to my script? Like how in win, it's .bat
In Windows/DOS the system recognizes a file to be executable by its "extension", e.g: .cmd, .exe, .pif, .scr.....
In Linux "executabitlity" of a file is a filesystem right. "Extensions" dont have meaning in Linux. (The only way a GNU/Linux system uses the pattern of file names is with hidden files: they start with a dot).
To give every user on the system the execute-right on a file, enter this on console/terminal:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.