[MACTCL] standalone wish debugging

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

[MACTCL] standalone wish debugging

james tittle
hiya,

...maybe I'm missing something, but here's my problem:  I've got an  
application that lives inside the standalone Wish.app and can't get  
gdb to load it...when the app is launched, it loads a tcl script that  
then starts a second binary in Contents/Resources/bin, and it's this  
second app that actually does the stuff I'm interested in  
debugging...however, in Xcode you have to select an executable to  
launch, and I'm guessing that it just loads the wish shell into the  
gdb instead of the secondary app...

...is there anyway around this?

jamie


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Tcl-mac mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-mac
Reply | Threaded
Open this post in threaded view
|

[MACTCL] Re: standalone wish debugging

Jim Ingham
Debugging an app that is exec'ed from another app is not entirely  
trivial.  We don't have the ability to follow from the parent into  
the child side of a fork on Mac OS X - I need some kernel support to  
do this which I don't have yet.  So you can't run Wish under gdb, and  
then debug into the child process.

The best way to do this - if you have the source for the app you are  
exec'ing - is to put a spin loop at the top of the main in your  
second app, like:

     int wait = 1;

     while (wait)
       sleep (1);

Run the Wish Shell normally.  Load the second app into gdb, and then  
when Wish exec's the second app, do:

(gdb) attach SecondApp
...
(gdb) break <WHEREVER>
(gdb) set wait = 0
(gdb) continue

If there's more than one copy of SecondApp running, you will have to  
find the PID of the copy you want to debug, and do:

(gdb) attach <PID>

You can also do this in Xcode, but you have to use the console to do  
the attach in Xcode 2.1.  This will be fixed so you can attach from  
the GUI in 2.2.

Jim

On Sep 9, 2005, at 9:12 AM, james tittle wrote:

> hiya,
>
> ...maybe I'm missing something, but here's my problem:  I've got an  
> application that lives inside the standalone Wish.app and can't get  
> gdb to load it...when the app is launched, it loads a tcl script  
> that then starts a second binary in Contents/Resources/bin, and  
> it's this second app that actually does the stuff I'm interested in  
> debugging...however, in Xcode you have to select an executable to  
> launch, and I'm guessing that it just loads the wish shell into the  
> gdb instead of the secondary app...
>
> ...is there anyway around this?
>
> jamie
>



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Tcl-mac mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-mac
Reply | Threaded
Open this post in threaded view
|

[MACTCL] #!/usr/bin/wish

Michael McFarlane
I'm trying to run a very simple script, simple.tcl:

~~~~~~~~ start file simple.tcl ~~~~~~~~
#!/usr/bin/wish

label .title -text "hello world"
button .abort -text "done" -command "destroy ."
pack .title .abort -side top
~~~~~~~~~ end file simple.tcl ~~~~~~~~~

When I run it, I get the following errors:

tcsh: label: Command not found.
tcsh: button: Command not found.
tcsh: pack: Command not found.

I get similar errors if I run from a Bourne shell.  I know that my example
will work if I replace the first line with:

#!/bin/sh
# the next line restarts using wish \
exec wish "$0" "$@"

But I believe that it should work the way that I originally wrote it.  Is
this an unsupported syntax on the Mac implementation of Tcl/Tk?

Thanks,
Mike




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Tcl-mac mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-mac
Reply | Threaded
Open this post in threaded view
|

Re: [MACTCL] #!/usr/bin/wish

Oscar Bonilla
How are you running your script?

On Sep 9, 2005, at 11:48 AM, Michael McFarlane wrote:

> I'm trying to run a very simple script, simple.tcl:
>
> ~~~~~~~~ start file simple.tcl ~~~~~~~~
> #!/usr/bin/wish
>
> label .title -text "hello world"
> button .abort -text "done" -command "destroy ."
> pack .title .abort -side top
> ~~~~~~~~~ end file simple.tcl ~~~~~~~~~
>
> When I run it, I get the following errors:
>
> tcsh: label: Command not found.
> tcsh: button: Command not found.
> tcsh: pack: Command not found.
>
> I get similar errors if I run from a Bourne shell.  I know that my  
> example
> will work if I replace the first line with:
>
> #!/bin/sh
> # the next line restarts using wish \
> exec wish "$0" "$@"
>
> But I believe that it should work the way that I originally wrote  
> it.  Is
> this an unsupported syntax on the Mac implementation of Tcl/Tk?
>
> Thanks,
> Mike
>
>
>
>
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle  
> Practices
> Agile & Plan-Driven Development * Managing Projects & Teams *  
> Testing & QA
> Security * Process Improvement & Measurement * http://www.sqe.com/ 
> bsce5sf
> _______________________________________________
> Tcl-mac mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/tcl-mac
>

--
pgp fingerprint: BC64 2E7A CAEF 39E1 9544  80CA F7D5 784D FB46 16C1



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Tcl-mac mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-mac
Reply | Threaded
Open this post in threaded view
|

Re: [MACTCL] #!/usr/bin/wish

Michael McFarlane
After creating simple.tcl, I do a "chmod +x simple.tcl".  Then, I just type
"simple.tcl".

By the way, I'm running TclTkAqua 8.4.10.


On 2005/09/09 2:05 PM, "Oscar Bonilla" <[hidden email]> wrote:

> How are you running your script?
>
> On Sep 9, 2005, at 11:48 AM, Michael McFarlane wrote:
>
>> I'm trying to run a very simple script, simple.tcl:
>>
>> ~~~~~~~~ start file simple.tcl ~~~~~~~~
>> #!/usr/bin/wish
>>
>> label .title -text "hello world"
>> button .abort -text "done" -command "destroy ."
>> pack .title .abort -side top
>> ~~~~~~~~~ end file simple.tcl ~~~~~~~~~
>>
>> When I run it, I get the following errors:
>>
>> tcsh: label: Command not found.
>> tcsh: button: Command not found.
>> tcsh: pack: Command not found.
>>
>> I get similar errors if I run from a Bourne shell.  I know that my
>> example
>> will work if I replace the first line with:
>>
>> #!/bin/sh
>> # the next line restarts using wish \
>> exec wish "$0" "$@"
>>
>> But I believe that it should work the way that I originally wrote
>> it.  Is
>> this an unsupported syntax on the Mac implementation of Tcl/Tk?
>>
>> Thanks,
>> Mike
>>
>>
>>
>>
>> -------------------------------------------------------
>> SF.Net email is Sponsored by the Better Software Conference & EXPO
>> September 19-22, 2005 * San Francisco, CA * Development Lifecycle
>> Practices
>> Agile & Plan-Driven Development * Managing Projects & Teams *
>> Testing & QA
>> Security * Process Improvement & Measurement * http://www.sqe.com/
>> bsce5sf
>> _______________________________________________
>> Tcl-mac mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/tcl-mac
>>
>
> --
> pgp fingerprint: BC64 2E7A CAEF 39E1 9544  80CA F7D5 784D FB46 16C1




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Tcl-mac mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-mac
Reply | Threaded
Open this post in threaded view
|

Re: [MACTCL] #!/usr/bin/wish

Oscar Bonilla
Weird. I asked you because it looks like tcsh is the one running the  
commands, not wish or tclsh...

see what's in /usr/bin/wish, it should be something like:

#!/bin/sh
"$(dirname $0)/../../System/Library/Frameworks/Tk.framework/Versions/
8.4/Resources/Wish Shell.app/Contents/MacOS/Wish Shell" "$@"

if so, then try

$ /usr/bin/wish simple.tcl

On Sep 9, 2005, at 12:16 PM, Michael McFarlane wrote:

> After creating simple.tcl, I do a "chmod +x simple.tcl".  Then, I  
> just type
> "simple.tcl".
>
> By the way, I'm running TclTkAqua 8.4.10.
>
>
> On 2005/09/09 2:05 PM, "Oscar Bonilla" <[hidden email]> wrote:
>
>
>> How are you running your script?
>>
>> On Sep 9, 2005, at 11:48 AM, Michael McFarlane wrote:
>>
>>
>>> I'm trying to run a very simple script, simple.tcl:
>>>
>>> ~~~~~~~~ start file simple.tcl ~~~~~~~~
>>> #!/usr/bin/wish
>>>
>>> label .title -text "hello world"
>>> button .abort -text "done" -command "destroy ."
>>> pack .title .abort -side top
>>> ~~~~~~~~~ end file simple.tcl ~~~~~~~~~
>>>
>>> When I run it, I get the following errors:
>>>
>>> tcsh: label: Command not found.
>>> tcsh: button: Command not found.
>>> tcsh: pack: Command not found.
>>>
>>> I get similar errors if I run from a Bourne shell.  I know that my
>>> example
>>> will work if I replace the first line with:
>>>
>>> #!/bin/sh
>>> # the next line restarts using wish \
>>> exec wish "$0" "$@"
>>>
>>> But I believe that it should work the way that I originally wrote
>>> it.  Is
>>> this an unsupported syntax on the Mac implementation of Tcl/Tk?
>>>
>>> Thanks,
>>> Mike
>>>
>>>
>>>
>>>
>>> -------------------------------------------------------
>>> SF.Net email is Sponsored by the Better Software Conference & EXPO
>>> September 19-22, 2005 * San Francisco, CA * Development Lifecycle
>>> Practices
>>> Agile & Plan-Driven Development * Managing Projects & Teams *
>>> Testing & QA
>>> Security * Process Improvement & Measurement * http://www.sqe.com/
>>> bsce5sf
>>> _______________________________________________
>>> Tcl-mac mailing list
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/tcl-mac
>>>
>>>
>>
>> --
>> pgp fingerprint: BC64 2E7A CAEF 39E1 9544  80CA F7D5 784D FB46 16C1
>>
>
>
>
>
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle  
> Practices
> Agile & Plan-Driven Development * Managing Projects & Teams *  
> Testing & QA
> Security * Process Improvement & Measurement * http://www.sqe.com/ 
> bsce5sf
> _______________________________________________
> Tcl-mac mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/tcl-mac
>

--
pgp fingerprint: BC64 2E7A CAEF 39E1 9544  80CA F7D5 784D FB46 16C1



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Tcl-mac mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-mac
Reply | Threaded
Open this post in threaded view
|

Re: [MACTCL] #!/usr/bin/wish

Michael McFarlane
My /usr/bin/wish is almost identical to yours, except that I don't have
"System" in my path.  If I run my script by typing either "/usr/bin/wish
simple.tcl" or just "wish simple.tcl", then it works fine.  However, I
believe that I should be able to just run "simple.tcl" as long as simple.tcl
is an executable file.


On 2005/09/09 2:42 PM, "Oscar Bonilla" <[hidden email]> wrote:

> Weird. I asked you because it looks like tcsh is the one running the
> commands, not wish or tclsh...
>
> see what's in /usr/bin/wish, it should be something like:
>
> #!/bin/sh
> "$(dirname $0)/../../System/Library/Frameworks/Tk.framework/Versions/
> 8.4/Resources/Wish Shell.app/Contents/MacOS/Wish Shell" "$@"
>
> if so, then try
>
> $ /usr/bin/wish simple.tcl
>
> On Sep 9, 2005, at 12:16 PM, Michael McFarlane wrote:
>
>> After creating simple.tcl, I do a "chmod +x simple.tcl".  Then, I
>> just type
>> "simple.tcl".
>>
>> By the way, I'm running TclTkAqua 8.4.10.
>>
>>
>> On 2005/09/09 2:05 PM, "Oscar Bonilla" <[hidden email]> wrote:
>>
>>
>>> How are you running your script?
>>>
>>> On Sep 9, 2005, at 11:48 AM, Michael McFarlane wrote:
>>>
>>>
>>>> I'm trying to run a very simple script, simple.tcl:
>>>>
>>>> ~~~~~~~~ start file simple.tcl ~~~~~~~~
>>>> #!/usr/bin/wish
>>>>
>>>> label .title -text "hello world"
>>>> button .abort -text "done" -command "destroy ."
>>>> pack .title .abort -side top
>>>> ~~~~~~~~~ end file simple.tcl ~~~~~~~~~
>>>>
>>>> When I run it, I get the following errors:
>>>>
>>>> tcsh: label: Command not found.
>>>> tcsh: button: Command not found.
>>>> tcsh: pack: Command not found.
>>>>
>>>> I get similar errors if I run from a Bourne shell.  I know that my
>>>> example
>>>> will work if I replace the first line with:
>>>>
>>>> #!/bin/sh
>>>> # the next line restarts using wish \
>>>> exec wish "$0" "$@"
>>>>
>>>> But I believe that it should work the way that I originally wrote
>>>> it.  Is
>>>> this an unsupported syntax on the Mac implementation of Tcl/Tk?
>>>>
>>>> Thanks,
>>>> Mike
>>>>
>>>>
>>>>
>>>>
>>>> -------------------------------------------------------
>>>> SF.Net email is Sponsored by the Better Software Conference & EXPO
>>>> September 19-22, 2005 * San Francisco, CA * Development Lifecycle
>>>> Practices
>>>> Agile & Plan-Driven Development * Managing Projects & Teams *
>>>> Testing & QA
>>>> Security * Process Improvement & Measurement * http://www.sqe.com/
>>>> bsce5sf
>>>> _______________________________________________
>>>> Tcl-mac mailing list
>>>> [hidden email]
>>>> https://lists.sourceforge.net/lists/listinfo/tcl-mac
>>>>
>>>>
>>>
>>> --
>>> pgp fingerprint: BC64 2E7A CAEF 39E1 9544  80CA F7D5 784D FB46 16C1
>>>
>>
>>
>>
>>
>> -------------------------------------------------------
>> SF.Net email is Sponsored by the Better Software Conference & EXPO
>> September 19-22, 2005 * San Francisco, CA * Development Lifecycle
>> Practices
>> Agile & Plan-Driven Development * Managing Projects & Teams *
>> Testing & QA
>> Security * Process Improvement & Measurement * http://www.sqe.com/
>> bsce5sf
>> _______________________________________________
>> Tcl-mac mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/tcl-mac
>>
>
> --
> pgp fingerprint: BC64 2E7A CAEF 39E1 9544  80CA F7D5 784D FB46 16C1




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Tcl-mac mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-mac
Reply | Threaded
Open this post in threaded view
|

Re: [MACTCL] #!/usr/bin/wish

Oscar Bonilla
Yes, that is the case... the other thing you might want to try is to do

$ sh -x ./simple.tcl

or

$ tcsh -x ./simple.tcl

and see what gets printed...

On Sep 9, 2005, at 12:54 PM, Michael McFarlane wrote:

> My /usr/bin/wish is almost identical to yours, except that I don't  
> have
> "System" in my path.  If I run my script by typing either "/usr/bin/
> wish
> simple.tcl" or just "wish simple.tcl", then it works fine.  However, I
> believe that I should be able to just run "simple.tcl" as long as  
> simple.tcl
> is an executable file.
>
>
> On 2005/09/09 2:42 PM, "Oscar Bonilla" <[hidden email]> wrote:
>
>
>> Weird. I asked you because it looks like tcsh is the one running the
>> commands, not wish or tclsh...
>>
>> see what's in /usr/bin/wish, it should be something like:
>>
>> #!/bin/sh
>> "$(dirname $0)/../../System/Library/Frameworks/Tk.framework/Versions/
>> 8.4/Resources/Wish Shell.app/Contents/MacOS/Wish Shell" "$@"
>>
>> if so, then try
>>
>> $ /usr/bin/wish simple.tcl
>>
>> On Sep 9, 2005, at 12:16 PM, Michael McFarlane wrote:
>>
>>
>>> After creating simple.tcl, I do a "chmod +x simple.tcl".  Then, I
>>> just type
>>> "simple.tcl".
>>>
>>> By the way, I'm running TclTkAqua 8.4.10.
>>>
>>>
>>> On 2005/09/09 2:05 PM, "Oscar Bonilla" <[hidden email]> wrote:
>>>
>>>
>>>
>>>> How are you running your script?
>>>>
>>>> On Sep 9, 2005, at 11:48 AM, Michael McFarlane wrote:
>>>>
>>>>
>>>>
>>>>> I'm trying to run a very simple script, simple.tcl:
>>>>>
>>>>> ~~~~~~~~ start file simple.tcl ~~~~~~~~
>>>>> #!/usr/bin/wish
>>>>>
>>>>> label .title -text "hello world"
>>>>> button .abort -text "done" -command "destroy ."
>>>>> pack .title .abort -side top
>>>>> ~~~~~~~~~ end file simple.tcl ~~~~~~~~~
>>>>>
>>>>> When I run it, I get the following errors:
>>>>>
>>>>> tcsh: label: Command not found.
>>>>> tcsh: button: Command not found.
>>>>> tcsh: pack: Command not found.
>>>>>
>>>>> I get similar errors if I run from a Bourne shell.  I know that my
>>>>> example
>>>>> will work if I replace the first line with:
>>>>>
>>>>> #!/bin/sh
>>>>> # the next line restarts using wish \
>>>>> exec wish "$0" "$@"
>>>>>
>>>>> But I believe that it should work the way that I originally wrote
>>>>> it.  Is
>>>>> this an unsupported syntax on the Mac implementation of Tcl/Tk?
>>>>>
>>>>> Thanks,
>>>>> Mike
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -------------------------------------------------------
>>>>> SF.Net email is Sponsored by the Better Software Conference & EXPO
>>>>> September 19-22, 2005 * San Francisco, CA * Development Lifecycle
>>>>> Practices
>>>>> Agile & Plan-Driven Development * Managing Projects & Teams *
>>>>> Testing & QA
>>>>> Security * Process Improvement & Measurement * http://www.sqe.com/
>>>>> bsce5sf
>>>>> _______________________________________________
>>>>> Tcl-mac mailing list
>>>>> [hidden email]
>>>>> https://lists.sourceforge.net/lists/listinfo/tcl-mac
>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> pgp fingerprint: BC64 2E7A CAEF 39E1 9544  80CA F7D5 784D FB46 16C1
>>>>
>>>>
>>>
>>>
>>>
>>>
>>> -------------------------------------------------------
>>> SF.Net email is Sponsored by the Better Software Conference & EXPO
>>> September 19-22, 2005 * San Francisco, CA * Development Lifecycle
>>> Practices
>>> Agile & Plan-Driven Development * Managing Projects & Teams *
>>> Testing & QA
>>> Security * Process Improvement & Measurement * http://www.sqe.com/
>>> bsce5sf
>>> _______________________________________________
>>> Tcl-mac mailing list
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/tcl-mac
>>>
>>>
>>
>> --
>> pgp fingerprint: BC64 2E7A CAEF 39E1 9544  80CA F7D5 784D FB46 16C1
>>
>
>
>
>
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle  
> Practices
> Agile & Plan-Driven Development * Managing Projects & Teams *  
> Testing & QA
> Security * Process Improvement & Measurement * http://www.sqe.com/ 
> bsce5sf
> _______________________________________________
> Tcl-mac mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/tcl-mac
>

--
pgp fingerprint: BC64 2E7A CAEF 39E1 9544  80CA F7D5 784D FB46 16C1



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Tcl-mac mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-mac
Reply | Threaded
Open this post in threaded view
|

Re: [MACTCL] #!/usr/bin/wish

steffen@ics.mq.edu.au
In reply to this post by Michael McFarlane
Michael,

On 10/09/2005, at 4:48, Michael McFarlane wrote:

> I'm trying to run a very simple script, simple.tcl:
>
> ~~~~~~~~ start file simple.tcl ~~~~~~~~
> #!/usr/bin/wish
>
> label .title -text "hello world"
> button .abort -text "done" -command "destroy ."
> pack .title .abort -side top
> ~~~~~~~~~ end file simple.tcl ~~~~~~~~~
>
> When I run it, I get the following errors:
>
> tcsh: label: Command not found.
> tcsh: button: Command not found.
> tcsh: pack: Command not found.
>
> I get similar errors if I run from a Bourne shell.  I know that my
> example
> will work if I replace the first line with:
>
> #!/bin/sh
> # the next line restarts using wish \
> exec wish "$0" "$@"
>
> But I believe that it should work the way that I originally wrote it.  
> Is
> this an unsupported syntax on the Mac implementation of Tcl/Tk?

yes, because /usr/bin/wish is itself a script and not a binary
executable, and so is not used as a shell for your script, causing your
current shell tcsh to attempt to run the script directly.
The only supported commands in a #! line are binary executables.

It is exactly for this reason that it has been recommended for a very
long time (before Mac OS X even existed) that the second technique
(i.e. exec wish) be used, because both /usr/bin/tcsh and /usr/bin/wish
are allowed to be shell scripts calling e.g. different binaries
depending on platform.

If you really need the first syntax, you have to replace /usr/bin/wish
by a copy (or hardlink) of the wish executable itself; you'll need a
recent version of Tk for this to work correctly and you'll loose some
of the features of the bundled Wish.app (dock icon, apple
scriptability).

Cheers,

Daniel

--
** Daniel A. Steffen     **  "And now for something completely
** Dept. of Mathematics  **   different"    Monty Python
** Macquarie University  **  <mailto:[hidden email]>
** NSW 2109 Australia    **  <http://www.maths.mq.edu.au/~steffen/>



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Tcl-mac mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-mac
Reply | Threaded
Open this post in threaded view
|

Re: [MACTCL] #!/usr/bin/wish

Oscar Bonilla
Ah, then he can also use the env trick...

#!/usr/bin/env wish

On Sep 9, 2005, at 9:43 PM, Daniel A. Steffen wrote:

> Michael,
>
> On 10/09/2005, at 4:48, Michael McFarlane wrote:
>
>
>> I'm trying to run a very simple script, simple.tcl:
>>
>> ~~~~~~~~ start file simple.tcl ~~~~~~~~
>> #!/usr/bin/wish
>>
>> label .title -text "hello world"
>> button .abort -text "done" -command "destroy ."
>> pack .title .abort -side top
>> ~~~~~~~~~ end file simple.tcl ~~~~~~~~~
>>
>> When I run it, I get the following errors:
>>
>> tcsh: label: Command not found.
>> tcsh: button: Command not found.
>> tcsh: pack: Command not found.
>>
>> I get similar errors if I run from a Bourne shell.  I know that my  
>> example
>> will work if I replace the first line with:
>>
>> #!/bin/sh
>> # the next line restarts using wish \
>> exec wish "$0" "$@"
>>
>> But I believe that it should work the way that I originally wrote  
>> it.  Is
>> this an unsupported syntax on the Mac implementation of Tcl/Tk?
>>
>
> yes, because /usr/bin/wish is itself a script and not a binary  
> executable, and so is not used as a shell for your script, causing  
> your current shell tcsh to attempt to run the script directly.
> The only supported commands in a #! line are binary executables.
>
> It is exactly for this reason that it has been recommended for a  
> very long time (before Mac OS X even existed) that the second  
> technique (i.e. exec wish) be used, because both /usr/bin/tcsh and /
> usr/bin/wish are allowed to be shell scripts calling e.g. different  
> binaries depending on platform.
>
> If you really need the first syntax, you have to replace /usr/bin/
> wish by a copy (or hardlink) of the wish executable itself; you'll  
> need a recent version of Tk for this to work correctly and you'll  
> loose some of the features of the bundled Wish.app (dock icon,  
> apple scriptability).
>
> Cheers,
>
> Daniel
>
> --
> ** Daniel A. Steffen     **  "And now for something completely
> ** Dept. of Mathematics  **   different"    Monty Python
> ** Macquarie University  **  <mailto:[hidden email]>
> ** NSW 2109 Australia    **  <http://www.maths.mq.edu.au/~steffen/>
>
>
>
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle  
> Practices
> Agile & Plan-Driven Development * Managing Projects & Teams *  
> Testing & QA
> Security * Process Improvement & Measurement * http://www.sqe.com/ 
> bsce5sf
> _______________________________________________
> Tcl-mac mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/tcl-mac
>

--
pgp fingerprint: BC64 2E7A CAEF 39E1 9544  80CA F7D5 784D FB46 16C1



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Tcl-mac mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-mac
Reply | Threaded
Open this post in threaded view
|

Re: [MACTCL] #!/usr/bin/wish

Michael McFarlane
Yikes, I've never seen that syntax before, but it works!  Thanks to both of
you for your help.


On 2005/09/10 12:18 AM, "Oscar Bonilla" <[hidden email]> wrote:

> Ah, then he can also use the env trick...
>
> #!/usr/bin/env wish
>
> On Sep 9, 2005, at 9:43 PM, Daniel A. Steffen wrote:
>
>> Michael,
>>
>> On 10/09/2005, at 4:48, Michael McFarlane wrote:
>>
>>
>>> I'm trying to run a very simple script, simple.tcl:
>>>
>>> ~~~~~~~~ start file simple.tcl ~~~~~~~~
>>> #!/usr/bin/wish
>>>
>>> label .title -text "hello world"
>>> button .abort -text "done" -command "destroy ."
>>> pack .title .abort -side top
>>> ~~~~~~~~~ end file simple.tcl ~~~~~~~~~
>>>
>>> When I run it, I get the following errors:
>>>
>>> tcsh: label: Command not found.
>>> tcsh: button: Command not found.
>>> tcsh: pack: Command not found.
>>>
>>> I get similar errors if I run from a Bourne shell.  I know that my
>>> example
>>> will work if I replace the first line with:
>>>
>>> #!/bin/sh
>>> # the next line restarts using wish \
>>> exec wish "$0" "$@"
>>>
>>> But I believe that it should work the way that I originally wrote
>>> it.  Is
>>> this an unsupported syntax on the Mac implementation of Tcl/Tk?
>>>
>>
>> yes, because /usr/bin/wish is itself a script and not a binary
>> executable, and so is not used as a shell for your script, causing
>> your current shell tcsh to attempt to run the script directly.
>> The only supported commands in a #! line are binary executables.
>>
>> It is exactly for this reason that it has been recommended for a
>> very long time (before Mac OS X even existed) that the second
>> technique (i.e. exec wish) be used, because both /usr/bin/tcsh and /
>> usr/bin/wish are allowed to be shell scripts calling e.g. different
>> binaries depending on platform.
>>
>> If you really need the first syntax, you have to replace /usr/bin/
>> wish by a copy (or hardlink) of the wish executable itself; you'll
>> need a recent version of Tk for this to work correctly and you'll
>> loose some of the features of the bundled Wish.app (dock icon,
>> apple scriptability).
>>
>> Cheers,
>>
>> Daniel
>>
>> --
>> ** Daniel A. Steffen     **  "And now for something completely
>> ** Dept. of Mathematics  **   different"    Monty Python
>> ** Macquarie University  **  <mailto:[hidden email]>
>> ** NSW 2109 Australia    **  <http://www.maths.mq.edu.au/~steffen/>
>>
>>
>>
>> -------------------------------------------------------
>> SF.Net email is Sponsored by the Better Software Conference & EXPO
>> September 19-22, 2005 * San Francisco, CA * Development Lifecycle
>> Practices
>> Agile & Plan-Driven Development * Managing Projects & Teams *
>> Testing & QA
>> Security * Process Improvement & Measurement * http://www.sqe.com/
>> bsce5sf
>> _______________________________________________
>> Tcl-mac mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/tcl-mac
>>
>
> --
> pgp fingerprint: BC64 2E7A CAEF 39E1 9544  80CA F7D5 784D FB46 16C1




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Tcl-mac mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-mac