From: Geoff B. <ge...@mr...> - 2006-07-24 15:50:21
|
The third line is a sh command to run expectk and pass the script to it (and any additional arguments). When expectk runs the script, you don't want to it to see this line, as it won't be valid tcl (since it's a sh command to restart the script!) The trick here is the \ at the end of line 2. In Tcl this line continuation means that line 3 is treated as a comment too, whereas in sh this line is executed. See eg. http://wiki.tcl.tk/706 Geoff. Gary Finley wrote: > On 24-Jul-06, at 6:18 AM, David Zolli wrote: > > >>Le 20 juil. 06 à 17:28, Gary Finley a écrit : >> >>>I have done a chmod a+x on the script and used this first line: >>>#!/Library/Tcl/bin/expectk -f >>> >>>However, when I run the script I get a string of errors indicating >>>that it was processed by my current shell (/bin/tcsh in this case), >>>rather than expectk. Is there something special that I have to do in >>>OSX to make an executable expectk script? Thanks. >> >>If you want it to be run with double-click you have to rename it with >>".command" extension. And rather than invoking expectk directly, try >>to call it with exec : >> >>#!/bin/sh >># the next line restarts using expectk \ >>exec /Library/Tcl/bin/expectk -f "$0" "$@" > > > Thanks David. That does solve my problem. With this edit, I can now > run the script from the command line as I wanted. With the .command > extension I can also run it via a double click in the Finder, if I > change the file's "Open With" property to terminal.app. > > Could you please explain why the above does not work without the > second line? When I chopped that line out for brevity, I get the error: > > Error in startup script: can't read "0": no such variable > while executing > "exec /Library/Tcl/bin/expectk -f "$0" "$@"" > > --------------- > Gary Finley > Director of Networking, Netera Alliance Inc. > Univ of Calgary (Mon, Thr): (403) 220-2571 > Canmore Office (Tue, Wed, Fri): (403) 678-6660 > Cell: (403) 615-6661 http://www.netera.ca/~gfin > > > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Tcl-mac mailing list > tc...@li... > https://lists.sourceforge.net/lists/listinfo/tcl-mac |