Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In bash, I can do something like this:

echo "The name of this script is $0"

Is there a way to do something similar in expect?

share|improve this question
Can't answer my own question since I don't have the rep -- but I figured it out: puts "The name of this script is $argv0" – Runcible Jun 1 '11 at 19:15
Note that argv0 is a global variable, so if you're doing that in a procedure, you need to either declare global argv0 or specify the variable in the global namespace $::argv0 – glenn jackman Jun 14 '11 at 16:36
From man expect: argv0 is defined to be the name of the script (or binary if no scriptis used). For example, the following prints out the name of the script and the first three arguments: send_user "$argv0 [lrange $argv 0 2]\n" – Paweł Brodacki Sep 25 '11 at 8:22

argv0 is a global variable that is defined to be the name of the script.

This question is answered in the comments above by @Runcible . Just adding this answer so this question shows up as answered correctly.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.