Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...This has been the MOST helpful forum that I have been a part of and I want to say thank you. The tips, tricks and helpful advice that you all contribute to have been lifesavers in many instances..."

Geography

Where in the world do Tek-Tips members come from?

Passing command-line arguments to Tcl

GeorgeLewis (Programmer)
19 Nov 99 10:18
Is there any way to pass command-line arguments to a script?

For example, I am writing a parsing program and would like to specify the settings.
I don't want to delve into creating and reading values from checkbox, radio button, or text widgets, etc.
in Tk if I don't have to do it.

The simple solution to me would be to use the command-line. But, I don't know if Tcl allows you to
use the command-line. For example, I would call my parser to print all the procedures in a Tcl script:
Parser.tcl
crossrad (Programmer)
26 Nov 99 17:41
The command line arguments are available inside a script
as global variables:

argv0 is the name of the script
argv is a list of the arguments
argc is the number of arguments
(equal to [llength $argv])

Hence the following script should print out the arguments:

#!/bin/sh
# The next line runs tclsh, passing the \
# arguments of this shell script to it. \
exec tclsh "$0" "$@"

puts "Command line arguments: $argv ($argc)"

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close