• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1509
  • Last Modified:

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.
0
gs_kanata
Asked:
gs_kanata
  • 2
1 Solution
 
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

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now