: Under Solaris, I always use the following lines in my perl code to : invoke it:
Newsgroups: comp.unix.shell,comp.lang.perl.misc,comp.os.linux.misc
: Under Solaris, I always use the following lines in my perl code to : invoke it:
: #!/bin/sh -- # -*- perl -*- -w : eval 'exec perl $0 ${1+"$@"}' : if 0;
If you use
#! /usr/bin/env perl
as the first line of your script, then it will be run using whatever copy of perl is found first on your path. I know this trick works on both RH Linux and Solaris, and believe that it will work on most Unix systems.
The problem with using
#! /usr/bin/perl
for the first line, as suggested by some others, is that perl is often installed in /usr/local/bin/perl instead. (if it doesn't come with the system and is installed later by the sys admin).
Paul Hughett
documented on: 2001.03.22 Thu 17:04:22
If you create a Tcl script in a file whose first line is
#!/usr/local/bin/tclsh
then you can invoke the script file directly from your shell if you mark the file as executable. This assumes that tclsh has been installed in the default location in /usr/local/bin; if it's installed somewhere else then you'll have to modify the above line to match. Many UNIX systems do not allow the #! line to exceed about 30 characters in length, so be sure that the tclsh executable can be accessed with a short file name.
An even better approach is to start your script files with the following three lines:
#!/bin/sh # the next line restarts using tclsh \ exec tclsh "$0" "$@"
This approach has three advantages over the approach in the previous paragraph. First, the location of the tclsh binary doesn't have to be hard-wired into the script: it can be anywhere in your shell search path. Second, it gets around the 30-character file name limit in the previous approach. Third, this approach will work even if tclsh is itself a shell script (this is done on some systems in order to handle multiple architectures or operating systems: the tclsh script selects one of several binaries to run). The three lines cause both sh and tclsh to process the script, but the exec is only executed by sh. sh processes the script first; it treats the second line as a comment and executes the third line. The exec statement cause the shell to stop processing and instead to start up tclsh to reprocess the entire script. When tclsh starts up, it treats all three lines as comments, since the backslash at the end of the second line causes the third line to be treated as part of the comment on the second line.
documented on: 1999.10.07 Thu 10:03:28
When running the tkdiff, I got the following error:
bash: tkdiff: No such file or directory
I knew it mush related to #! magic word but it looks ok:
#!/bin/sh
after add -x, I realize that it was the file format which is causing the trouble. It was a dos format file.
So,
![]() |
"No such file or directory" now has two reasons: 1. unfound command. 2. wrong file format. |
documented on: 2000.03.04 Sat 13:44:25
#!/bin/sh /usr/atria/bin/cleartool setview -exec '/clearlib/admin/tools/ViewMan.pl' DEFAULT_VIEW
change it to
#!/usr/atria/bin/cleartool setview -exec '/clearlib/admin/tools/ViewMan.pl' DEFAULT_VIEW
and it will not work any more.
Because of aforementioned "30-character file name limit".
documented on: 2007.06.12