On Wed, 9 May 2001, Federico Sevilla III wrote:
> ----------[ Begin Shell View ]----------
> jijo@kalapati:~$ mv rmmod wahmod
> jijo@kalapati:~$ ./wahmod
> The insmod/modprobe/rmmod/ksyms/lsmod/kallsyms combined binary does not
> have a recognisable name, the name must contain one of insmod, modprobe,
> rmmod, ksyms, lsmod or kallsyms.
> ----------[ End Shell View ]----------
> 
> So now we know it's called a "combined binary". Perhaps someone's got some
> techie answer to this. Interesting trivial thingie, for me at least. :)

it's an old technique. recall that disk space was expensive in the early
days and every little bit squeezed out of real estate was worth saving. to
conserve space, we have all sorts of neat tricks like hard links and
symbolic links and stuff like what you just demonstrated. 

sometimes you have programs that complement each other, like gzip and
gunzip, where their functions are basically just the reverse of the other.
sometimes the only difference is a flag or a switch in the program source
itself. if you check gzip/gunzip, they are actually just the same file
with different handles. do an ls -i /bin/g*zip and just to make sure i'm
not pulling your leg. they have the same inode number. they is the same
file (pardon my grammar).

how differently the program works is based on the name of the program as
it is called. hee, someone just posted a neat shell script that
illustrated this to the list but i'll continue anyhoo.

recall in C that the prototype for the main function is:

        int main(int argc, char *argv[]);

where argc holds the number of command-line arguments and argv, an array
of pointers to those same arguments.

argv[0] will always hold the name of the command as it was called.

so it is simply a matter of using the contents of argv[0] in your control
of the program's execution.

here's a really short c program along the same lines as what KidPogi
posted. it doesn't use any control structures but will provide
interestingly different results if named in a variety of ways.

--> cut here <--
int
main(int argc, char *argv[])
{
        printf("Hello %s!\n", argv[0]);
}
--> cut here <--

Compile it, name the binary whatever you want. Then run it.

Have fun. ;)

___ eric pareja ([EMAIL PROTECTED]) ~-=[O]=-~ Here, have a clue. Get the picture.
\@/ PGP key at http://gra.ph/~xenos/xenos.pgp <|PLUG|> http://gra.ph
 v  "Even the smallest person can change the course of the future."
    - Lady Galadriel in J.R.R. Tolkien's "The Lord of the Rings"



_
Philippine Linux Users Group. Web site and archives at http://plug.linux.org.ph
To leave: send "unsubscribe" in the body to [EMAIL PROTECTED]

To subscribe to the Linux Newbies' List: send "subscribe" in the body to 
[EMAIL PROTECTED]

Reply via email to