Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem with argv0 (newbie question)

156 views
Skip to first unread message

ashok

unread,
Aug 31, 2005, 5:35:27 AM8/31/05
to
Hi,

I am trying to print the name of the current executable using the
following statment:

puts "\n $argv0"

However, I get the following error message & the program exits:

can't read "argv0": no such variable

I tried using "global argv0" at the beginning of the proc too but that
doesn't help.

Is there anything else that I should watch out for?

Thanks,
Ashok

Donald Arseneau

unread,
Aug 31, 2005, 6:38:53 AM8/31/05
to
"ashok" <ashok....@gmail.com> writes:

> can't read "argv0": no such variable
>
> I tried using "global argv0" at the beginning of the proc too but that
> doesn't help.

That is the answer, so it should work. Are you sure you didn't have
a typo?


--
Donald Arseneau as...@triumf.ca

suchenwi

unread,
Aug 31, 2005, 6:51:45 AM8/31/05
to
..or is the executable a custom one, with Tcl embedded? The
conveniences of argv0 etc. are only available with tclsh, or Tcl_Main,
or by doing what Tcl_Main does.

Michael A. Cleverly

unread,
Aug 31, 2005, 9:10:53 AM8/31/05
to
On Wed, 31 Aug 2005, ashok wrote:

> However, I get the following error message & the program exits:
>
> can't read "argv0": no such variable
>
> I tried using "global argv0" at the beginning of the proc too but that
> doesn't help.
>
> Is there anything else that I should watch out for?

Are you using a "stock" tclsh? What does:

puts [lsort [info globals]]

show in your environment?

Michael

ashok

unread,
Sep 1, 2005, 3:45:10 AM9/1/05
to
Hello,

Thanks for all your suggestions.

Here's how I solved the issue. I used "set program_name [ info
nameofexecutable ]" & the name of the program preceded by the path gets
printed.

Regards,
Ashok

0 new messages