English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

What commands would I need to write a program 'doit' that takes another Unix/Linux command as an argument and executes that command. For example executing

doit cat /etc/motd

would invoke the cat command on the file /etc/motd which will print the current "message of the day".

Any help appreciated!

2006-08-27 09:25:22 · 1 answers · asked by petre 1 in Computers & Internet Programming & Design

1 answers

Most shell interpreters don't *need* a 'doit' program - just saying 'cat /etc/motd' is sufficient But if you feel the need to do it the hard way (at the expense of a few extra fork/exec pairs you'd not have done the easy way), this should work:

/bin/sh -c "/bin/cat /etc/motd"

2006-08-27 10:20:15 · answer #1 · answered by Valdis K 6 · 0 0

fedest.com, questions and answers