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

    Join Date
    Jul 2012
    Posts
    6
    Rep Power
    0

    C shell self-reference


    I have a delete c shell scripts that deletes a bunch of things in some folders, and then chmod 666 's itself (to prevent accidental deleting) by explictitly writing the file name

    Code:
    #delete.csh
    rm -rf work/
    cd log
    rm -rf *
    cd ..
    chmod 666 delete.csh
    How can I get it to know what file it is, if that makes sense

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

    Join Date
    Jun 2005
    Posts
    4,381
    Rep Power
    1871
    Try this
    Code:
    #!/bin/csh
    echo $0
    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
    Jul 2012
    Posts
    6
    Rep Power
    0

    Thumbs up


    That worked, thanks!

IMN logo majestic logo threadwatch logo seochat tools logo