Previous 1 2 Next 22 Replies Latest reply: Feb 19, 2008 9:21 AM by Tim Semic Go to original post
  • Gnarlodious Level 4 Level 4 (3,225 points)
    What you need to do is put your script on the clipboard then run this Applescript:

    set the clipboard to "<div style='font-family: Monaco;width: 90%; margin: auto; padding: 5px; border: 1px solid #B1B5B9; background: #EEEFF1;'>" & (the clipboard) & "</div>"


    The resulting text is placed on the clipboard, which is what you paste in the editing window.

    You can customise to your heart's delight. I believe Apple even has a built-in CSS class for scripts, you would have to examine the source for a page to see what it is.

    My Applescript menu is set up so that HTML wrapper scripts are in front when my browser is, for easy handling.
  • Tim Semic Level 1 Level 1 (130 points)
    Ok,
    Trying to paste the script again...

    <begin-script>

    #!/bin/sh
    # The following script rotates out the oldest log file by renaming them.
    echo ""
    printf %s "Rotating log files:"
    cd /var/log
    for i in daily-backup.log; do
    if [ -f "${i}" ]; then
    printf %s " ${i}"
    if [ -x /usr/bin/gzip ]; then gzext=".gz"; else gzext=""; fi
    if [ -f "${i}.6${gzext}" ]; then mv -f "${i}.6${gzext}" "${i}.7${gzext}"; fi
    if [ -f "${i}.5${gzext}" ]; then mv -f "${i}.5${gzext}" "${i}.6${gzext}"; fi
    if [ -f "${i}.4${gzext}" ]; then mv -f "${i}.4${gzext}" "${i}.5${gzext}"; fi
    if [ -f "${i}.3${gzext}" ]; then mv -f "${i}.3${gzext}" "${i}.4${gzext}"; fi
    if [ -f "${i}.2${gzext}" ]; then mv -f "${i}.2${gzext}" "${i}.3${gzext}"; fi
    if [ -f "${i}.1${gzext}" ]; then mv -f "${i}.1${gzext}" "${i}.2${gzext}"; fi
    if [ -f "${i}.0${gzext}" ]; then mv -f "${i}.0${gzext}" "${i}.1${gzext}"; fi
    if [ -f "${i}" ]; then
    touch "${i}.$$" && chmod 640 "${i}.$$" && chown root:admin "${i}.$$"
    mv -f "${i}" "${i}.0" && mv "${i}.$$" "${i}" && if [ -x /usr/bin/gzip ]; then
    gzip -9 "${i}.0"; fi
    fi
    fi
    done
    # The following line creates a backup of the data drive onto the backup drive.
    rsync -aEv /Volumes/data/ /Volumes/backup >> /var/log/daily-backup.log 2>&1
    # Mails a truncated log file wo/forks to the happy admin.
    grep -v '._' /var/log/daily-backup.log | mail -s "rsync-backup on MacServe1" me@domain.com



    <end-script>
  • Gnarlodious Level 4 Level 4 (3,225 points)
    You actually ran the Applescript 3 times, so the clipboard is wrapped in 3 divboxes.

    But you get the idea.
  • Tim Semic Level 1 Level 1 (130 points)
    Yes, thanks for the script. However what I am pasting in is not verbose. You see the html entries, my script does not have those in there. And the 1. in the script are actually comments, pound signs.

    I looked at the help for text formatting but it did not show how to enter code. I'll take the liberty to try a couple of things here.

    <pre> blah </pre>

    and

    <code> blah </code>

    and

    ::
    blah

    Hopefully one of those.
  • Tim Semic Level 1 Level 1 (130 points)
    <pre>#!/bin/sh
    # The following script rotates out the oldest log file by renaming them.
    echo ""
    printf %s "Rotating log files:"
    cd /var/log
    for i in daily-backup.log; do
    if [ -f "${i}" ]; then
    printf %s " ${i}"
    if [ -x /usr/bin/gzip ]; then gzext=".gz"; else gzext=""; fi
    if [ -f "${i}.6${gzext}" ]; then mv -f "${i}.6${gzext}" "${i}.7${gzext}"; fi
    if [ -f "${i}.5${gzext}" ]; then mv -f "${i}.5${gzext}" "${i}.6${gzext}"; fi
    if [ -f "${i}.4${gzext}" ]; then mv -f "${i}.4${gzext}" "${i}.5${gzext}"; fi
    if [ -f "${i}.3${gzext}" ]; then mv -f "${i}.3${gzext}" "${i}.4${gzext}"; fi
    if [ -f "${i}.2${gzext}" ]; then mv -f "${i}.2${gzext}" "${i}.3${gzext}"; fi
    if [ -f "${i}.1${gzext}" ]; then mv -f "${i}.1${gzext}" "${i}.2${gzext}"; fi
    if [ -f "${i}.0${gzext}" ]; then mv -f "${i}.0${gzext}" "${i}.1${gzext}"; fi
    if [ -f "${i}" ]; then
    touch "${i}.$$" && chmod 640 "${i}.$$" && chown root:admin "${i}.$$"
    mv -f "${i}" "${i}.0" && mv "${i}.$$" "${i}" && if [ -x /usr/bin/gzip ]; then
    gzip -9 "${i}.0"; fi
    fi
    fi
    done

    # The following line creates a backup of the data drive onto the backup drive.
    rsync -aEv /Volumes/data/ /Volumes/backup >> /var/log/daily-backup.log 2>&1

    # Mails a truncated log file wo/forks to the happy admin.
    grep -v '._' /var/log/daily-backup.log | mail -s "rsync-backup on MacServe1" me@domain.com</pre>
  • Charles Minow Level 6 Level 6 (9,190 points)
    To post code, use the word "code" inside two curly braces: "{" and "}". Sort of like this:

    { code }

    but without the spaces between the "code" and the braces. And put the same tag at the end.

    Something like:

    if [ -f "${i}" ]; then
    printf %s " $i"
    if [ -x /usr/bin/gzip ]; then gzext=".gz"; else gzext=""; fi
    if [ -f "${i}.3${gzext}" ]; then mv -f "${i}.3${gzext}" "${i}.4${gzext}"; fi
    if [ -f "${i}.2${gzext}" ]; then mv -f "${i}.2${gzext}" "${i}.3${gzext}"; fi
    if [ -f "${i}.1${gzext}" ]; then mv -f "${i}.1${gzext}" "${i}.2${gzext}"; fi
    if [ -f "${i}.0${gzext}" ]; then mv -f "${i}.0${gzext}" "${i}.1${gzext}"; fi
    if [ -f "${i}" ]; then mv -f "${i}" "${i}.0" && if [ -x /usr/bin/gzip ]; then gzip -9 "${i}.0"; fi; fi
    touch "${i}" && chmod 640 "${i}" && chown root:admin "${i}"
    fi


    charlie
  • Tim Semic Level 1 Level 1 (130 points)
    Ok, another attempt to get this script posted:


    #!/bin/sh
    # The following script rotates out the oldest log file by renaming them.
    echo ""
    printf %s "Rotating log files:"
    cd /var/log
    for i in daily-backup.log; do
    if [ -f "${i}" ]; then
    printf %s " ${i}"
    if [ -x /usr/bin/gzip ]; then gzext=".gz"; else gzext=""; fi
    if [ -f "${i}.6${gzext}" ]; then mv -f "${i}.6${gzext}" "${i}.7${gzext}"; fi
    if [ -f "${i}.5${gzext}" ]; then mv -f "${i}.5${gzext}" "${i}.6${gzext}"; fi
    if [ -f "${i}.4${gzext}" ]; then mv -f "${i}.4${gzext}" "${i}.5${gzext}"; fi
    if [ -f "${i}.3${gzext}" ]; then mv -f "${i}.3${gzext}" "${i}.4${gzext}"; fi
    if [ -f "${i}.2${gzext}" ]; then mv -f "${i}.2${gzext}" "${i}.3${gzext}"; fi
    if [ -f "${i}.1${gzext}" ]; then mv -f "${i}.1${gzext}" "${i}.2${gzext}"; fi
    if [ -f "${i}.0${gzext}" ]; then mv -f "${i}.0${gzext}" "${i}.1${gzext}"; fi
    if [ -f "${i}" ]; then
    touch "${i}.$$" && chmod 640 "${i}.$$" && chown root:admin "${i}.$$"
    mv -f "${i}" "${i}.0" && mv "${i}.$$" "${i}" && if [ -x /usr/bin/gzip ]; then
    gzip -9 "${i}.0"; fi
    fi
    fi
    done
    # The following line creates a backup of the data drive onto the backup drive.
    rsync -aEv /Volumes/data/ /Volumes/backup >> /var/log/daily-backup.log 2>&1
    # Mails truncated log file to the happy admin.
    grep -v '._' /var/log/daily-backup.log | mail -s "rsync-backup on MacServe1" me@domain.com
  • Tim Semic Level 1 Level 1 (130 points)
    Thanks Charles.

    The cool thing about that script is that I implemented Apple's rotating log script which can be used for just about anything. Very handy for logging your script results.
Previous 1 2 Next