Find the answer to your Linux question:
Results 1 to 4 of 4
OK, I've created a sh file to delete a cache folder for one of my sites. Basically, the bash looks like this: Code: #!/bin/bash rm -fdr cached* mkdir cached chmod ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined! vexx's Avatar
    Join Date
    Aug 2007
    Posts
    4

    Unhappy Bash file problem


    OK, I've created a sh file to delete a cache folder for one of my sites. Basically, the bash looks like this:

    Code:
    #!/bin/bash
    rm -fdr cached*
    mkdir cached
    chmod 0777 cached
    When I launch it within the console (root), it does not delete the cached folder and when I "ls -l", I always find another folder called "cached\r".

    The cached folder has 0777 permissions all the time, owner root, group root.

    The funny part is, I have another site, on the same server, different account and this bash works perfectly.

    If I run the commands individually from the console, works perfectly...

    I'm puzzled

  2. #2
    Just Joined! minigeek's Avatar
    Join Date
    Sep 2005
    Location
    New Zealand
    Posts
    31
    Quote Originally Posted by vexx View Post
    OK, I've created a sh file to delete a cache folder for one of my sites. Basically, the bash looks like this:

    Code:
    #!/bin/bash
    rm -fdr cached*
    mkdir cached
    chmod 0777 cached
    When I launch it within the console (root), it does not delete the cached folder and when I "ls -l", I always find another folder called "cached\r".

    The cached folder has 0777 permissions all the time, owner root, group root.

    The funny part is, I have another site, on the same server, different account and this bash works perfectly.

    If I run the commands individually from the console, works perfectly...

    I'm puzzled
    Hi

    Is the script running in the same directory as the "cached" file?

    Does the script run via a cron job?


  3. #3
    Just Joined! vexx's Avatar
    Join Date
    Aug 2007
    Posts
    4
    no..i launch the script with the "sh file.sh" command.

    the sh file is in root with all the folders, including "cached"

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined! minigeek's Avatar
    Join Date
    Sep 2005
    Location
    New Zealand
    Posts
    31
    Try running the script with sh -x
    sh -x file.sh

    This will output the process to the console so it can be checked for errors.

    or run diff to compare the two script.

    diff /path/to/working/script path/to/non-working/script

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •