Shell scripting stuff

REMEMBER! No matter who is providing a script or knowledge, BACKUP EARLY, BACKUP OFTEN. If you are not comfortable running a shell script, don't do this!

This is about find, but extends into how a shell script is integrated in "C" or Python. The orange text is commands executed at the shell prompt and green indicates the contents of a file. find is the base command /home/ The path comes next and this as an example will search user space -name "*.blend" and the thing to search for You will notice the quotes here which is to keep the shell expansion from modifying the wild card to expand it. I could use -name fred if I was just looking for fred, as it would not be fiddled with by the command interpreter expansion methods. So all together it is find /home/ -name "*.blend" and this will return a list of all files that match this wild card set. I can pipe that to sort or any number of other programs to use the results or just find out where something has wandered off to or even find dups so I can get rid of junk.
I tried the command to see if something odd happened and it complained a little as it went into directories that it was not allowed to use, but one odd thing is that it found a .blend file in my sauerbraten source tree that I didn't know was there. That was k001. I also found another in a package that is a script for morphing human and other models and the output blend file. (I guess I snarfed that somewhere and forgot to test it :)

A shell script file ( must be chmod +x to execute)

#Uncomment next line to get debug output set -x echo "PATH is $PATH used as \$PATH" echo "\$# is the number of command line arguments, which is $#." echo "\$0 is the name of the program running and is $0" echo "Always exit with a status like exit 0 or exit 127" exit 0

A "C" code program that executes shell commands or scripts. It is the contents of a file named program.c I put "return 0;" in it to make it clean.

int main(int argc, char *argv[]){
system ("ls -l program*");
return 0;
How to compile the program. The option -o sets what the output executable file will be called (otherwise it will just be called "a.out").

gcc -o program program.c

How to run the program


I can include any other program or script or perl or python in a C file or I can compile and link also, but for Q&D this is a way.

BTB Here is a link to something in this same vein at Microwave Biscuit , but a bit more elegant if this bores you.


Automated Intelligence

Automated Intelligence
Auftrag der unendlichen LOL katzen