|
|
Log in / Subscribe / Register

Follow up: How to write a Linux virus

Follow up: How to write a Linux virus

Posted Feb 20, 2009 10:42 UTC (Fri) by nix (subscriber, #2304)
In reply to: Follow up: How to write a Linux virus by aleXXX
Parent article: Follow up: How to write a Linux virus

Yay.

I didn't think of #!/usr/bin/env xdg-open, but that works nicely. (I'm not
sure if the /usr/bin/env is actually required: how common is it to have
xdg-open anywhere else?)


to post comments

using #!/usr/bin/env

Posted Feb 20, 2009 19:53 UTC (Fri) by biged (guest, #50106) [Link]

It may not be common for programs to be found in other places, but when it is done, it may be done for very good reasons. Therefore /usr/bin/env should be the strongly preferred mechanism for all scripts.

The use-case I am familiar with is configuration management and site-wide installations. The calling process has PATH constructed to collect a carefully managed set of versions of programs together, and scripts work well when they respect the PATH.

Environment Modules (http://modules.sourceforge.net/) is a very usable approach. (The tcl implementation is the better version, in my experience.)

It comes down to control: the script user knows their needs and their environment, more so than the script writer. In a multi-user, multi-machine environment, a surprising wide variety of tool collections can be made to work, often on a monoculture of old distributions: in my case, RHEL3 until recently.

In a hardware or silicon engineering environment, being able to freeze and re-use a versioned collection of tools some years after they were originally current is very useful. I think it also has applicability in a software engineering environment.

Please, do use #!/usr/bin/env, even if it doesn't seem well-motivated on a single-user short-lived installation.

Follow up: How to write a Linux virus

Posted Feb 20, 2009 23:17 UTC (Fri) by mp (subscriber, #5615) [Link] (1 responses)

It is required for execve to work, as xdg-open is itself a script.

Follow up: How to write a Linux virus

Posted Feb 22, 2009 21:24 UTC (Sun) by nix (subscriber, #2304) [Link]

Aha! For some reason it hadn't occurred to me that the env trick could be
used to allow scripts to be interpreters as well as to allow interpreters
to be located anywhere, but of course it can. :)


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds