Why TCL exec chmod does not work?

From the command line, I could run the following commad without question:

chmod 755 <dir>/*

However, if I did the same thing via TCL/Expect

exec chmod 755 <dir>/*

I got the error as:

ERROR: chmod: WARNING: can't access <dir>/*

permission is not an issue. Feel like TCL does not recognize <dir> correctly.
gs_kanataAsked:
Who is Participating?
 
AwesomeMachineCommented:
The exec command doesn't use a shell, so you have to invoke a shell:

 tclsh % exec /bin/sh -c "chmod 755 <dir>/*"

The -c switch just means treat the following as a string. That way /bin/sh knows what you want. There are other methods also, but this one works closest to how you want it to work.
0
 
pegasysCommented:
% file attributes foobar -permissions 0755;

changing attribs is the same as using file.. man "file" and have a look at the -permissions argument :)
0
 
gs_kanataAuthor Commented:
file attributes does not work multiple files under certain directory in TCL language.

file attributes foodir/* -permissions 0755

will get

could not set permissions for file "foodir/*": no such file or directory
0
 
pegasysCommented:
is this a specific directory? or all?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.