#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2010
    Posts
    1
    Rep Power
    0

    Help needed for shell programming


    Hello
    This is my first time writing a shell..I have been asked to a program to change the current default directory..to <directory>. If the <directory> argument is not present, report the current directory. If the directory does not exist an appropriate error should be reported.
    I know the cd command so also I know how to write a program in C. But how do I chekc if the directory is present or not ?I am not getting how to use cd command in a program..

    Please help..
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,387
    Rep Power
    1871

    Post


    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2010
    Posts
    5
    Rep Power
    0
    Code:
    -d
    should be valid argument for it.

    say

    [ -d $DIR ]

IMN logo majestic logo threadwatch logo seochat tools logo