views:

97

answers:

3

I have a need to create a utility in Suze Linux. The utility will make modifications to some text files, and then use the information in those text files to program a device in the computer using a different executable which accepts command line parameters.

I am fluent in c#, but have never worked with Linux. Should I take the time to learn Gnu C++ to do this, or install Mono? How would I execute the programming utility and pass it command line parameters?

+1  A: 

In C and C++ there's system("command arguments") which you can use to execute a command using the system's interpreter (i.e. you can use it as though you had typed in the command in the shell). The command string can be constructed at runtime. I'm not very familiar with C#, but if I recall correctly you can use Process and ProcessStartInfo classes to run system commands.

Arkku
+1  A: 

Based on the complexity of your program I'd recommend using a scripting language like Perl. It's always a good idea to have a scripting language in your toolbox.

juharr
Thanks, but I think I'll stick with something familiar for now.
Robert Harvey
+1  A: 

Is there a reason you want to restrict yourself to only C++ or C#? There are many options you could consider, for example:

For very simple tasks:

  • Bash: In some cases a simple Bash script will be able to solve the task. Piping information from one process to another is a breeze, and you have the power of sed, awk, etc. at your fingertips. Another major advantage is that it is installed almost everywhere.

For slightly more involved tasks you could try a scripting language:

  • Python: Easy to learn, pleasant to read. Very useful for putting together small applications quickly. You can use subprocess to communicate with other processes.
  • Ruby: Similar comments to Python - a good scripting language with a clean syntax.
  • Perl: Perl is very good at processing text, although personally I dislike the syntax.

Other options:

  • Java: Your C# experience will allow you to learn Java quickly as it is a very similar language. Java is officially supported on Linux.
  • C#: A lot of Linux users are wary of C# because it isn't free enough, but obviously that isn't a worry for you. It has worked fine the few times I've tried it. Note that Mono is not 100% compatible with Microsoft's version.
  • C++: For what you're planning to do I personally wouldn't recommend C++. It will solve the task though, and if you already know some C++ then I guess it is worth considering.

Obviously there are many other suitable options too.

Mark Byers
What we are considering right now is using c#/Windows for the text processing (his office computer is a windows machine, and something like BASH to automate the programming on the Linux box.
Robert Harvey
@Robert Harvey: Bash is a very useful tool on Linux. It's good at glueing other applications together rather than being a good programming language in its own right. You should definitely take a look at it, but if you need to write more than 10 lines or so of shell script, you might want to consider if another tool would be more suitable. Bash is good at dealing with processes and files, but painful for mathematical calculations.
Mark Byers
Looks like I will probably do everything in c#. There's not time to learn a new language. Installing things on Linux is a PITA (trying to resolve dependencies), but Mono has a Suse Linux disk you can download with everything installed, so I think I'm set.
Robert Harvey