Last active
February 1, 2017 22:15
-
-
Save snobu/da0fe3a589350e61d5bcbd718fe3da37 to your computer and use it in GitHub Desktop.
Read command line arguments in TLC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| puts "Script executed with $argc arguments" | |
| set msg "" | |
| foreach i $argv { | |
| append msg $i | |
| # Append comma if there's more than one argument | |
| if {$i ne [lindex $argv $argc-1]} { | |
| append msg ", " | |
| } | |
| } | |
| puts "SYSLOG_MSG: $msg" | |
| # Expected output: | |
| # | |
| # $ tclsh args.tcl ONE TWO THREE | |
| # Script executed with 3 arguments | |
| # SYSLOGMSG: ONE, TWO, THREE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment