Why TCL exec chmod does not work?

Posted on 2011-10-13
Last Modified: 2012-05-12
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.
Question by:gs_kanata
    LVL 3

    Accepted Solution

    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.
    LVL 7

    Expert Comment

    % file attributes foobar -permissions 0755;

    changing attribs is the same as using file.. man "file" and have a look at the -permissions argument :)

    Author Comment

    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
    LVL 7

    Expert Comment

    is this a specific directory? or all?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
    Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now