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.
Ok ok, but what I am looking for is what can I do with the shell command that would be helpful for me. Also how do I make a file and how do i execute the files.
What can you program? Whatever you want within limits of the current state of the art.
For Bash programming (assuming you're using a Bash shell), start here http://tldp.org/LDP/abs/html/index.html. Create the file in a text editor...nano , vi ,vim, emacs, gedit, kate, kedit, mousepad, etc., etc., etc. Set the executable bit on the script file to make it executable
Code:
chmod +x filename
For making executable files using C++, you need to compile it and link it with g++. That will provide you with an executable binary. Start here to learn how to use the compilers provided by gcc http://gcc.gnu.org/onlinedocs/.
Last edited by weibullguy; 02-28-2007 at 06:13 PM.
Ok ok, but what I am looking for is what can I do with the shell command that would be helpful for me. Also how do I make a file and how do i execute the files.
Hello and welcome. I don't know a lot about programming, but I think I can help. The only language I know is C++. The compiler you will be using is the gnu compiler.
At the command line you need to use a text editor such as vim, emacs, or nano to create your source file. Nano will be the easiest to use at first, but vim and emacs are much more powerful. For example:
Code:
nano test.cpp
Then write your code and then save and exit. I believe Ctrl+O is save and Ctrl+X is exit. Next you need to compile. Assuming you have the gnu compiler installed type this:
Code:
g++ test.cpp
Now you should have a file named a.out in your current working directory. Type this to execute it:
Thank you Arow, that is what I was talking about, thanks.
Wee-Face, I am using KNOPPIX, I was wondering, If i save my config in a usb i have to run a little program to do it. Can I just run a script to take care of that every time. Maybe Knoppix already takes care of that but that is another question.
spinelli, i appreciate the cpp info. I do have experience programming in JAVA and C++ like I said. But extra info on how to execute was helpful.
Now that we are all still talking about programming, Is it possible for me to program in Windows and test scripts in a shell "emulator?"
If you want a bash enviroment in Windows, try Cygwin. I'm unsure how accurate it is to a real, live, linux system, but the alternative is QEmu and friends. Or perhaps a shell account somewhere.
I have never used any of these programs on Windows before, but it looks like they might be helpful to you. Also try googling "bash on windows" for more information.
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088
Rep:
For copying a config file (or set of files) to a USB stick, you just need to put the commands that you use into a text file, and make it executable. For example, if you regularly mount the drive, copy a file to it and unmount it again:
Code:
#! /bin/bash
mount /media/usb
cp /path/to/file /media/usb
umount /media/usb
As for testing scripts on Windows, Cygwin works well. You may find some differences with real Linux as opposed to Cygwin though.
Make the script executable, and run it as was previously shown.
I've used cygwin before and it's really quite useful, it is a
little slow compared to using a bash shell on a real system.
I learned bash scripting with cygwin and got started with
c on cygwin before deciding to finally move on to linux,
but i still use windows occasionally and still have cygwin
installed.
I've used cygwin before and it's really quite useful, it is a
little slow compared to using a bash shell on a real system.
I learned bash scripting with cygwin and got started with
c on cygwin before deciding to finally move on to linux,
but i still use windows occasionally and still have cygwin
installed.
If you're using knoppix you will probably have to write a script
to mount your device and store it on a floppy, which you will
then need to mount in order to execute the script, i could be
mistaken.
And the other approach is to embed windows in Linux, I'm using vmware so when I have to turn to windows it's there...
The question about what can I program is actually a very good question. I know very little about shell scripts because I have little need of them, when I do need them I struggle to get something working. The reason for this is most of my linux work is on the desktop. My view is as a single user doing tasks when I need them. Occasionally scripts are useful but I see them coming into their own when the view is as an administrator of multiple users. So scripts to extract data from log files, to manage user accounts starts to make some sense. When I find myself having to perform such tasks and tend to fall back onto non-shell scripting languages typically PHP because I know it fairly well.
So onto the second arena of programming compiled languages, there is a wealth of tool available on Linux, it's just a case that it takes time to learn these tools. Whatever it is that you program spend a little extra time learning about the debugger, tools that spot memory leeks, tools to create unit tests, tools to create documentation of your code, Each of these are important and will help to make you a better programmer. As to what you can do, if it's to learn do something that you enjoy, whilst keeping the above point in mind, then you will learn much more than you realise. As an example a friend of mine (many year ago) had a passion for music, he was interested in computers and so with some guidance he wrote his own synthesiser program (this was long before these programs were available) he never considered himself a programmer but in his field he was one of the best.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.