Thread: C File permissions

  1. #1
    Registered User
    Join Date
    Apr 2004
    Posts
    1

    C File permissions

    I am trying to do this task but dont seem to be getting any where can any1 help?

    Write a C shell script, exe, which changes the permissions of a file to make it executable by anyone.

    Usage

    The script takes one parameter and should be called as follows:

    exe filename


    Output

    Your script should use the chmod command to change the permissions of the file.
    Your script should output a message to the user to indicate that the file’s permissions have been changed.
    Your script should output an error message if any of the following error conditions occurs:
    • the user calls the script with the wrong number of parameters

    • the file does not exist


    • the file is not an ordinary file

    thanks in advance.

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Since you haven't posted any code to show an attempt and it should a lot like homework this is all the hint you'll get for now:

    Code:
    sprintf(buffer, "chmod %s", argv[1]);
    system(buffer);
    Before it just do the error checking on the number of parameters, file existing, file type.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems passing a file pointer to functions
    By smitchell in forum C Programming
    Replies: 4
    Last Post: 09-30-2008, 02:29 PM
  2. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM
  5. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM