Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with 'isdirectory'

Status
Not open for further replies.

ironmonkey69

Programmer
Aug 24, 2007
4
US
Hi all,

I have been having problems setting up an 'if' statement that is using a 'isdirectory' command. I pass a string into the if statement thru a command line argument. The backup file exists in the directory that it is looking in but the if statement keeps falling through. Here is a copy of the code that I am using:

proc test {args} {
for each new $args
if{[file isdirectory $args.original] == 1}
set dir "$args"
set dirOriginal "$args.original"
exec mv -f $dirOriginal $dir
 
This is what it actually looks like:

proc test {args} {
for each new $args
if{[file isdirectory $new.original] == 1}
set dir "$new"
set dirOriginal "$new.original"
exec mv -f $dirOriginal $dir
 
args is the argument taken in from the command line

ex. source /data/new/new.tcl /home/new.new.current.txt
 
no, you can use almost any variable that you choose, it can have almost any name. Can I get some help with the 'isdirectory' statement within the 'if' statement?
 
ironmonkey,
file isdirectory $new.original returns a boolean so the whole ==1 thing is redundant and may be causing your problem. I tested a simple example with:
if [file isdirectory $new.original] {[red]do something[/red]} and it worked fine.

The {} suppresses substitution so that could be an issue.

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top