Need some help with a script


wgstarks

Recommended Posts

I've set up a script to clean .DS_Store files. Got the script from this post

#!/bin/bash
# ========================================================================== #
# Program Body                                                               #
# ========================================================================== #
((!$#)) && echo No Directory supplied! && exit 1

dir="$@"
echo $dir

echo "Removing .DS_Store files"
find "$dir" -name ".DS_Store" -exec rm '{}' \; -print

echo "======================="
echo "Removing ._ files"
find "$dir" -name "._*" -exec rm '{}' \; -print

 

 

I've got it installed in /config/plugins/DS_Store-Cleanup/ and run it with a cron entry-

# DS_Store Cleanup for Media:
20 3 * * 1 ./config/plugins/DS_Store-Cleanup/rmdotstore.sh /mnt/user/Media

 

 

I think it's working??? If I create a test file named .DS_Store it will get deleted when running the command via telnet at least. My problem is that I don't get any notifications. Is there something I can modify to have the system send a notification (preferred) or maybe at least have a log entry?

Link to comment

Tried changing the script to this-

#!/bin/bash
# ========================================================================== #
# Program Body                                                               #
# ========================================================================== #
((!$#)) && echo No Directory supplied! && /usr/local/emhttp/plugins/dynamix/scripts/notify [-e "DS_Cleanup"] [-s "DS_Cleanup"] [-i "normal"] [-m "Cleaning DS_Store files from Media"] && exit 1

dir="$@"
echo $dir

echo "Removing .DS_Store files"
find "$dir" -name ".DS_Store" -exec rm '{}' \; -print

echo "======================="
echo "Removing ._ files"
find "$dir" -name "._*" -exec rm '{}' \; -print

 

I don't get an email though. Did I miss something?

 

Also tried running the command from telnet with the same result.

I'm guessing there's a syntax problem but I'm a noob at this so pretty much lost here.

Link to comment

Tried changing the script to this-

#!/bin/bash
# ========================================================================== #
# Program Body                                                               #
# ========================================================================== #
((!$#)) && echo No Directory supplied! && /usr/local/emhttp/plugins/dynamix/scripts/notify [-e "DS_Cleanup"] [-s "DS_Cleanup"] [-i "normal"] [-m "Cleaning DS_Store files from Media"] && exit 1

dir="$@"
echo $dir

echo "Removing .DS_Store files"
find "$dir" -name ".DS_Store" -exec rm '{}' \; -print

echo "======================="
echo "Removing ._ files"
find "$dir" -name "._*" -exec rm '{}' \; -print

 

I don't get an email though. Did I miss something?

 

Also tried running the command from telnet with the same result.

I'm guessing there's a syntax problem but I'm a noob at this so pretty much lost here.

duh... I'm dense.  Remove the braces from within the notify command
Link to comment

I've never used that style with bash

 

I always use if and fi - makes more sense to me. 

 

Probably would for me too if I had any idea what I was doing.:D

 

I just added it on to the cron script. Worked great. Thanks

# DS_Store Cleanup for Media:
20 3 * * 1 ./config/plugins/DS_Store-Cleanup/rmdotstore.sh /mnt/user/Media  && /usr/local/emhttp/plugins/dynamix/scripts/notify -e "DS_Cleanup" -d "Removing .DS_Store files" -i "normal" -m "Cleaning DS_Store files from Media"

 

I seem to remember that I need to restart my server for the cron files to load. Is that true?

Link to comment

Stole this from your post up above for my little code. Thanks for sharing. ;)

 

/usr/local/emhttp/plugins/dynamix/scripts/notify -e "DS_Cleanup" -d "Removing .DS_Store files" -i "normal" -m "Cleaning DS_Store files from Media"

 

Of course I modified it for my own needs, but I dig the notification.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.