These are expect parameter to work with command line options:
puts $argc # number of argument passed to script
puts $argv # array list of arguement, script name not included
puts $argv0 # the name of script include path of calling e.g. ./test.sh
set path [file dirname $argv0] # obtain script directory
cd $path # Change directory to script directory
# Find script path through links as well
set originalPath [pwd]
set scriptPath $::argv0
set workingPath [file dirname $::argv0]
while {![catch {file readlink $scriptPath} result]} {
cd $workingPath
set scriptPath [file join [pwd] $result]
set workingPath [file dirname $scriptPath]
}
cd [file dirname $scriptPath]
set scriptPath [pwd]
cd $originalPath
puts $argc # number of argument passed to script
puts $argv # array list of arguement, script name not included
puts $argv0 # the name of script include path of calling e.g. ./test.sh
set path [file dirname $argv0] # obtain script directory
cd $path # Change directory to script directory
# Find script path through links as well
set originalPath [pwd]
set scriptPath $::argv0
set workingPath [file dirname $::argv0]
while {![catch {file readlink $scriptPath} result]} {
cd $workingPath
set scriptPath [file join [pwd] $result]
set workingPath [file dirname $scriptPath]
}
cd [file dirname $scriptPath]
set scriptPath [pwd]
cd $originalPath
No comments:
Post a Comment