Python as Bash Replacement: coreutils?

Hello,
I want to start replacing my Bash scripts with Python ones, partly due to Python's performance being much better. However, all the modules I found whose goal is to aid replacing shell-scripting with Python, interface with the GNU coreutils through `subprocess`. As we all know, forking the process to call external programs is why shell scripts are that much slower.
I was wondering if there's a Python module/library that replaces the behaviours of the coreutils, so that I don't have to write them myself, e.g. a `tail` behaviour written in Python. Or any other modules/libs that would aid in shell-scripting with Python without `subprocess`.
Last edited by NewWorld (2014-03-22 07:38:36)

lykwydchykyn wrote:Well, "os" covers a lot of ground, but you probably knew that already.  I'm not sure how you'd expect python implementations of coreutils to be faster than the C versions that BASH is calling.
I have done research which concludes that shell scripts are a lot slower than Python. See this graph from this blog post, and this graph from this blog post.
This answer on SO gives an explanation for shell scripts being slower:
shell scripts are inherently slow, especially when they use a lot of external commands like yours. Biggest reason for this is because spawning external process is rather slow, and you do it a lot of times.
If you are really after high performance processing of your data, you should write Perl or Python script which would do what you need without ever spawning any external process: no dos2unix, no grep, no cut or anything like that.
@progandy, thanks a lot for the link. This module is also available for Python 2.7, which is what I'll be writing in.
tomk wrote:
NewWorld wrote:It's alpha and it's buggy
Maybe you could help make it beta and less buggy?
As I mentioned in the original post, I don't want to be writing  these tools myself; I'm already prone to RSI pain and that's just not how I want to spend my free time just to be able to write shell-scripts easier from within Python.

Similar Messages

  • Python for Bash scripters

    I've been doing bash scripts for a while and wanted to start actual programming, so I chose Python.
    Are there any guides that make learning python easier if you know bash?

    I used, and still do use, The Python Phrasebook by Brad Dayley. I find it handy for when I forget how to do something simple. It is a fairly simple book and as others have mentioned, the online python docs are very nice. The library reference in particuar.

  • [SOLVED]Recursively use makepkg with python...or bash!

    I am basically trying to build a base Archlinux system from scratch on my eee pc. I researched Pacbuild a little bit but decided to try my own had at this.
    After being completely unsuccessful at trying to write bash scripts with loops and variables and whatnot, I took a look at python. I basically just searched a bunch of python tutorials on google and came up with this. So..this being my first script and all I was wondering if this would be the right way to do this. It basically works except with no error checking and if I want it to stop i have to press ctrl-c until the loop ends...but other that it works fine.
    #! /usr/bin/env python
    #import bash commands
    import os
    import sys
    #open pkglist file
    pkglist = open('/home/rhune/list', 'r')
    pkgname = pkglist.readline() #read pkgname in file
    while len(pkgname) != 0:
    pkgname = pkgname.rstrip('\n') #delete newline
    os.chdir('/home/rhune/eeepkgs')
    os.chdir(pkgname) #cd /home/rhune/pkgname
    os.system('makepkg') #run makepkg in working dir
    os.chdir('/home/rhune/eeepkgs') #cd ../
    pkgname = pkglist.readline() #read pkgname in file
    pkglist.close() #close file
    The "list" file is a list of folders in the directory im pointing to.
    I also plan on having it accept an argument of what folder to run in and using the tempfile to create the directory list, and with some sort of error checking. But thats a whole nother project.
    Any comments or contributions appreciated!
    edit: is there a way to check if makepkg successfully compiles the package? i.e. does it return a 1 or 0 or some sort of value? Or would i have to parse the actual output of it?
    Last edited by rhune (2009-08-28 04:48:05)

    Thanks much! This works, just gotta pick a better place to store the output.
    #!/bin/bash
    cd $1
    for folder in $(find * -type d)
    do
    cd $folder
    makepkg -s
    if [ $? -gt 0 ]; then
    echo $folder >> '/home/rhune/failed'
    else
    echo $folder >> '/home/rhune/passed'
    fi
    cd ../
    done
    Also figured out this in python:
    !/usr/bin/env python
    import os
    import subprocess
    base = "/home/rhune/test/pkgs"
    failed=[]
    dir = os.listdir(base)
    dir.sort()
    os.chdir(base)
    print dir
    for x in range(len(dir)):
    os.chdir(dir[x])
    retcode = subprocess.call(['makepkg', '-s'])
    if retcode==1:
    failed.append(dir[x])
    os.chdir(base)
    print failed
    The bash one seems a bit simpler though.
    Also, this:
    #! /usr/bin/env python
    import os
    import sys
    deplist=[]
    depname=""
    count=0 #count apostrophes
    #search for depends= line in pkgbuild
    with open('/home/rhune/pkgs/yaourt/PKGBUILD', 'r') as pkg:
    for deps in pkg:
    if "depends" in deps: break
    deps=deps.strip('depends=')
    #insert depnames into deplist
    for x in deps:
    if x=="'": count+=1 #counts apostrophes
    if x.isalpha(): depname+=x
    if count==2:
    deplist.append(depname)
    depname="" #reset depname
    count=0 #reset count
    #pbget for each dependency in list
    for x in range(len(deplist)):
    os.system('pbget --arch=i686 '+deplist[x])
    Reads a PKGBUILD file and pbgets dependencies. Need to change sys to subprocess, didnt realize it was outdated. Still needs a little work, but its practically done. Also made a sed script to go through each directory and change the PKGBUILD to use gcc-4.5 for the atom optimization.
    #!/bin/bash
    cd $1
    ls -l
    for folder in $(find * -type d)
    do
    cd $folder
    sed -s 's/\.\/configure/CC=gcc-4.5 \.\/configure/' PKGBUILD > tmpfile ; mv tmpfile PKGBUILD
    cd ../
    done
    These being the first time ever writing any sort of scripts, i think im getting the hang of it. Thanks to a little (and i mean little) bit of c++ knowledge.
    So im basically ready to compile the whole system, hopefully itll all work!
    Thanks
    edit: also, maybe a stupid question, but why does $0 -gt 0 work? does the script return a 1 or 0 after each iteration or is it from makepkg?
    Last edited by rhune (2009-08-28 04:53:52)

  • Good Resources for learning Bash Scripting

    I know, I should probably be lectured for the fact that I'm a heavy Linux user who programs in a variety of languages, but is very limited when it comes to bash scripting itself.
    So, I've decided now is the time to learn. It seriously beats writing configuration scripts in C, I think (that's not really what C is used for these days...).
    So, anyone know of some good (preferably free) resources on learning Bash?
    Edit:
    OR if someone has any suggested alternatives (e.g., Python as a replacement?), do tell.
    Last edited by holland01 (2012-09-07 23:09:11)

    sisco311 wrote:Greg's Wiki
    +1
    See also: https://bbs.archlinux.org/viewtopic.php?id=103851 & https://bbs.archlinux.org/viewtopic.php?id=114288

  • Bash still worth learning?

    Today I needed to write a script that would copy a few of my dot files into a git repository. I cracked vim open and began to experiment with rudimentary bash constructs, but after a while gave up and decided to write the thing in Python, just because Python is simple and I know it.
    Are there any good reasons as to why I should pursue a knowledge of bash with other, higher level languages around (e.g. Python) when bash's breadth of use is (relatively) limited?

    Kiwi wrote:So what Xyne is saying is that Python sucks more than Bash? Unless, I suppose, if that is a vacuum made by Microsoft.
    Heh. Oh the flame wars!
    Cyrusm wrote:I say if you're comfortable with python, and it does what you need it to do, then use python. There is no real "need" to learn Bash imo.  personally I like bash for quick and dirty scripts, python for more elaborate scripts. but really it's just what ever you're happy using.
    Exactly my thoughts... If you can achieve the same thing 2 different ways and the result is the same, then do whatever is more comfortable/easier for you.
    Although, if you'll excuse this little anecdote..... I used to *hate* perl, with a passion. I'd go out of my way to avoid it, because I didn't know it and when I tried to use it I found it esoteric and painful. Over the last few months though I had managed to get a (basic) grasp of perl, and now I love it. It can make things so much easier than doing the same in bash. The reverse is also true.
    Moral of my anecdote (I think): Right Tool for the Right Job. The more tools you have (know), the easier to find a suitable tool for your task.

  • Bash debugger

    i built this as i wanted to debug my shell scripts (natch)
    first you have to patch and rebuild bash, i also used the stock Arch patch and PKGBUILD for this.  However, i am unclear on all the provides, replaces and conflicts crap - how the hell do you set these right so it replaces a core pkg without causing loads of errors and forcing you to use -Sfd?
    # Contributor: dibblethewrecker dibblethewrecker.at.jiwe.dot.org
    pkgname=bash-debug
    pkgver=3.0
    pkgrel=1
    pkgdesc="The GNU Bourne Again shell, rebuilt with debugger support"
    url="http://www.gnu.org/software/bash/bash.html"
    license=""
    backup=(etc/profile)
    depends=('glibc' 'readline')
    conflicts=('bash')
    replaces=('bash')
    provides=('bash')
    install=
    source=(ftp://ftp.cwru.edu/pub/bash/bash-3.0.tar.gz profile
    bash-history.patch http://heanet.dl.sourceforge.net/sourceforge/bashdb/bashdb-3.00-0.01.tar.gz)
    md5sums=('26c4d642e29b3533d8d754995bc277b3' '719b60711ee609850277bd0848516136'
    '7108b64d6b21b74764a602e142ca6b2c' '7f96a4cb9c9e124e19b20cba852bbbea')
    build() {
    # build bash built as for arch + bashdb patch
    cd $startdir/src/bash-3.0
    patch -Np1 -i ../bash-history.patch || return 1
    patch -Np1 -i ../bashdb-3.00-0.01/patch/bash-3.00.patch
    ./configure --prefix=/usr --with-curses --enable-readline --enable-debugger
    make || return 1
    make DESTDIR=$startdir/pkg install
    mv $startdir/pkg/usr/bin $startdir/pkg/bin
    # we don't want bashbug
    rm -f $startdir/pkg/bin/bashbug
    rm -f $startdir/pkg/usr/man/man1/bashbug.1
    install -D -m644 ../profile $startdir/pkg/etc/profile
    ln -sf bash $startdir/pkg/bin/sh
    and then this is the debugger itself - this one is a bit hacky as the configure is absolutely useless!
    # Contributor: dibblethewrecker dibblethewrecker.at.jiwe.dot.org
    pkgname=bashdb
    pkgver=3.00
    pkgrel=1
    pkgdesc=""
    url="http://bashdb.sourceforge.net"
    license=""
    backup=(etc/profile)
    makedepends=('bash-debug' 'texinfo')
    depends=('glibc' 'readline' 'bash-debug')
    source=(http://heanet.dl.sourceforge.net/sourceforge/bashdb/$pkgname-$pkgver-0.01.tar.gz)
    md5sums=('7f96a4cb9c9e124e19b20cba852bbbea')
    build() {
    # build bashdb
    cd $startdir/src/$pkgname-$pkgver-0.01
    # configure is PATHETIC but we'll run it anyway!
    ./configure --prefix=/usr
    # some really crappy hacks to get compile to finish!
    cat ./Makefile | sed "s|PKGDATADIR = /usr/local/lib/bashdb|PKGDATADIR = $startdir/pkg/usr/share/bashdb|g" >./Makefile.new && mv ./Makefile.new ./Makefile
    cat ./Makefile | sed "s|/usr/local/lib/bashdb|$startdir/pkg/usr/share/bashdb|g" >./Makefile.new && mv ./Makefile.new ./Makefile
    make || return 1
    make prefix=$startdir/pkg/usr install
    # make the symlink that configure can't make for us!
    ln -sf dbg-main.inc $startdir/pkg/usr/share/bashdb/bashdb-main.inc
    i haven't actually figured out how to use it - i have seen it running in emacs - which appears to make more user friendly but i have never used emacs
    EDIT: looks like ddd is the way to go with it - it was ddd i saw not emacs!

    um - i couldn't really get this to work and the recompiled bash was messing things up - any suggestions?  also ddd couldn't even find the debugger 

  • Python being changed to python2? 10/17/12

    I noticed with the latest pacman upgrade its asking to remove python packages and replace them with python2 packages. Is this something new in the pipeline?
    core                     107.7 KiB   491K/s 00:00 [######################] 100%
    extra                   1431.2 KiB   986K/s 00:01 [######################] 100%
    community               1785.8 KiB  1029K/s 00:02 [######################] 100%
    multilib is up to date
    :: Starting full system upgrade...
    :: Replace python-egenix-mx-base with extra/python2-egenix-mx-base? [Y/n] y
    :: Replace python-imaging with community/python2-imaging? [Y/n] y
    :: Replace python-notify with extra/python2-notify? [Y/n] y
    resolving dependencies...
    looking for inter-conflicts...
    Targets (23): dee-1.0.14-2  gwibber-3.4.2-2  hplip-3.12.10.a-3
                  pygobject-devel-3.2.2-2  pygobject2-devel-2.28.6-7
                  python-3.3.0-1  python-dbus-common-1.1.1-2
                  python-egenix-mx-base-3.2.4-1 [removal]
                  python-imaging-1.1.7-4 [removal]
                  python-notify-0.1.1-11 [removal]  python2-dbus-1.1.1-2
                  python2-distutils-extra-2.37-1  python2-egenix-mx-base-3.2.4-3
                  python2-gobject-3.2.2-2  python2-gobject2-2.28.6-7
                  python2-httplib2-0.7.6-1  python2-imaging-1.1.7-5
                  python2-lxml-3.0-1  python2-notify-0.1.1-12  python2-xdg-0.23-2
                  system-config-printer-common-1.3.11-2
                  system-config-printer-gnome-1.3.11-2  vlc-2.0.4-1
    Total Download Size:    41.71 MiB
    Total Installed Size:   197.15 MiB
    Net Upgrade Size:       17.72 MiB
    Proceed with installation? [Y/n]

    WorMzy wrote:Why are you saying no?
    Because, as far as I know, python2 has been replaced by python (which is python 3).
    Seems to me that there is something wrong causing a downgrade in these packages, since all these packages using python(3) are being changed to python2 on this upgrade attempt.
    Anyhow, replacing with python2 doesn't seems to solve the issue.
    :: Synchronizing package databases...
    core is up to date
    extra is up to date
    community 1779.7 KiB 290K/s 00:06 [######################] 100%
    multilib is up to date
    :: Starting full system upgrade...
    :: Replace python-gnomekeyring with extra/python2-gnomekeyring? [Y/n]
    :: Replace python-imaging with community/python2-imaging? [Y/n]
    :: Replace python-mpdclient2 with community/python2-mpdclient2? [Y/n]
    :: Replace python-musicbrainz2 with community/python2-musicbrainz2? [Y/n]
    :: Replace python-notify with extra/python2-notify? [Y/n]
    :: Replace python-opengl with extra/python2-opengl? [Y/n]
    :: Replace python-pysqlite with extra/python2-pysqlite? [Y/n]
    :: Replace python-rsvg with extra/python2-rsvg? [Y/n]
    resolving dependencies...
    looking for inter-conflicts...
    error: failed to prepare transaction (could not satisfy dependencies)
    :: arista-transcoder: requires python-rsvg
    :: fofix: requires python-opengl
    :: fofix: requires python-pysqlite
    :: fretsonfire: requires python-opengl
    :: puddletag: requires python-musicbrainz2>=0.6.0
    :: sofastats: requires python-pysqlite
    I have tried reinstalling both python and python2 without solution.

  • Preventing root from overwriting a file

    Is there any way to keep pacman (or other package managers that run as root) from overwriting a file in a directory where it would normally be overwritten? Without using the immutable flag (which only works on ext* filesystems)? I know this should strictly never be necessary, but if there is any way to render things read-only for root, I think it would be useful to know.

    Pacman creates .pacnew files for the files in backup array:
    [karol@black ~]$ sp -Qii initscripts
    Name : initscripts
    Version : 2011.07.3-1
    URL : http://www.archlinux.org
    Licenses : GPL2
    Groups : base
    Provides : None
    Depends On : glibc bash grep coreutils udev>=171 iproute2 ncurses kbd findutils
    sysvinit
    Optional Deps : bridge-utils: Network bridging support
    dhcpcd: DHCP network configuration
    net-tools: legacy network support
    wireless_tools: Wireless networking
    Required By : None
    Conflicts With : None
    Replaces : None
    Installed Size : 112,00 K
    Packager : Tom Gundersen <[email protected]>
    Architecture : i686
    Build Date : czw, 28 lip 2011, 14:42:30
    Install Date : nie, 31 lip 2011, 09:14:39
    Install Reason : Explicitly installed
    Install Script : Yes
    Description : System initialization/bootup scripts
    Backup Files:
    MODIFIED /etc/inittab
    MODIFIED /etc/rc.conf
    MODIFIED /etc/rc.local
    UNMODIFIED /etc/rc.local.shutdown
    UNMODIFIED /etc/conf.d/wireless

  • 32 bit apps, 64 bit environment 32bit chroot pacman32

    Well, I'm getting a little tired downloading excessive amounts of 32 bit libraries, and always missing some when ever I Want to install an aplication so I tried installing a 32 bit chroot environment again lightweight install
    http://wiki.archlinux.org/index.php/Arc … bit_system
    This section here is to better highlight the segment
    Create an alias for pacman32, the command to be used to install 32-bit packages. Just add the following line to your ~/.bashrc or similar:
    alias pacman32="pacman --root /opt/arch32 --cachedir /opt/arch32/var/cache/pacman/pkg --config /opt/arch32/pacman.conf"
    Sync pacman32:
    pacman32 -Sy
    Install basic packages for 32-bit subsystem. These are the minimal packages that allow you to chroot to the subsystem and run locale-gen script for i18n.
    pacman32 -S filesystem licenses bash sed coreutils gzip
    Now you are ready for the following steps. Remember that you should replace all pacman commands required to run the chroot environment with pacman32 under the 64-bit system.
    when I run pacman32 it says
    [edgar@myhost ~]$ pacman32 -Sy
    pacman: option '--config' requires an argument
    bash: /opt/arch32/pacman.conf: Permission denied
    I didn't quite get it since it seems 'right' to me o_O but I'm somewhat a noob when it comes to these sort of things really... well, at least this time around I can sort of read the commands properly XD... (Sort of)
    I just wanna be able of compiling, and installing 32 bit applications really :\
    Last edited by SirEdgar2nd (2010-06-03 19:34:10)

    Well...I no longer get the argument error o_O
    but now I have another issue, I can only use pacman32 as root...which is obviously like normal pacman but the thing is wouldn't I Need to add the alias thingy to whatever root uses as bashrc for that to work properly o-O?
    I wonder if thats what it meant by
    "Now you are ready for the following steps. Remember that you should replace all pacman commands required to run the chroot environment with pacman32 under the 64-bit system." :\  Blargh

  • Problem with firefox and chrome

    Hi guys,
    i've a problem with chrome. When i download something with google chrome and at the bottom i press on the file or show all downloads,  i'm redirected to firefox :0
    Tried also to uninstall firefox. No way, nothing happen if i press show all downloads or press on the downloaded file.
    Any advice?
    Thanks guys.

    Perhaps Mate isn't as gnome-like as I thought.  I just found this which looks to be a solution.
    Or, my solution to all xdg-open related problems: replace it.  I've writen a tiny script like below that I replace /usr/bin/xdg-open with so I can stay in control of what it is doing.
    #!/bin/bash
    # replacement for /usr/bin/xdg-open
    for f in $@; do mime=`file -b --mime-type "$f"`; case "$mime" in
    #MIME-TYPE) APPLICATION <END LINE WITH ;;>
    audio/*) mplayer "$f" ;;
    video/*) mplayer "$f" ;;
    */pdf) mupdf "$f" ;;
    esac; done > /dev/null 2>&1 &
      I would not recommend this script if you are not comfortable editting scripts as it does need customizing.  However, the alternate solution is to edit a much longer and much more confusing script.
    Edit: cleaned up my ugly script, as it is a work in progress.
    Last edited by Trilby (2012-05-14 15:46:54)

  • Sharing Only Accounts don't show in Users & Groups

    Hi,
    I've done a fresh install of Maverick yesterday.
    And I created a "Sharing Only" account so I can access my iMac from another PC (so it doesn't show up at logon time)
    When I went back in Users and Groups this morning, my newly "Sharing Only" account had gone.
    So I thought I'd forgotten it and tried to create it again: to my surprise at creation time, Mac OS reports: "Name is used by another user", when in fact it's not listed in the left sidebar (I can only see my accout and the guest account)
    I tried the same with a "Standard user" and all is fine.
    I tried with a second "Sharing Only" account and it disappeared too (after a logoff)
    I've found this article: http://support.apple.com/kb/TS4404 but I don't wanna screw up my fresh install
    Can anyone help?

    here also the same ... totally fresh out of the box Mac Mini with update to 10.9.2 ... create a share only user called "conf_share", add this user to a existing share ... go back to the User & Groups and paaaaaaaaaaaaaaaaaaaaaaaahhh it's disappear (but still existing of course)
    I found this "hint" but this is only usefull if you want to delete this user without going crazy... this hint will convert the sharing only user to a standard user
    Just type the following two commands in terminal:
    Quit and reopen System preferences and the sharing account will show up:
    sudo dscl . create /Users/root GeneratedUID FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000000
    and then:
    sudo dscl . create /Users/accountname UserShell /bin/bash
    Replace "accountname" in the commands above with the missing account name.

  • ANSI escape sequence for "Command" key?

    I know there are escape sequences for ctrl (^), alt (~), shift ($), etc that can be used from the command-line, but I'm wondering if there's an equivalent way to invoke the command key (or the apple key or whatever you wish to call it) from a terminal?
    I'd appreciate any advice, thanks!

    Hi Evan,
       This is more than a failure of terminology. The use of certain key sequences cause the terminal to produce certain characters that are just like letters except that many processes take special action when these characters are encountered. These characters are called "control characters."
       For instance, type <Control>-v to "tell the shell" to not take special action on the next character produced. Then, if you type <Control>-c, the terminal will produce an End-of-Text character, ANSII character 3, and the shell will accept it as a literal character. However, it has no symbol for that character so it displays a pair of characters, "^C", in its place. Internally though, there is no carat and no 'C'; there is only the number three, which is the ANSII code for the End-of-Text character.
       The bash shell will substitute control characters for certain escape sequences in expanding words of the form $'string'. For instance, consider the following command:
    echo $'\003' | cat -v
    ^C
    Above, the first line is a command that you can cut-and-paste into your terminal. The second line is the output you would see if you execute the command. Bash replaces the $'\003' word with the literal control character and then "cat" converts that character to the pair of characters, "^C", to show you what had been there.
       Of course there are still terminology problems; you are not using the word "emulate" correctly. However, if there was such a meaning, I think that one would say that the character sequences "emulate" the control character, not the other way around.
       On the other hand, when you modify a key with the "Command" key, Macintosh programs treat that as an attempt to invoke a function of that program. No character is produced. In fact technically, the program never even sees the keystrokes. The system intercepts the key event and converts it to an AppleEvent.
       One tool on Macs specializes in producing AppleEvents and that is AppleScript. Fortunately, Apple wrote a utility to grant the shell access to AppleScript and that is the "osascript" command. That allows you to sort of imbed AppleScript in a shell script and that would allow you to send any program any event that the system would generate in response to a command key sequence.
    Gary
    ~~~~
       "Home life as we understand it is no more natural to us
       than a cage is to a cockatoo."
          -- George Bernard Shaw

  • How to auto download a link with MP3 every week on the same time?

    Hi all,
    i found this website where weekly the radiostation that i listen to,
    posts the jazz show in mp3 format.
    The name of the link stays the same, is there a possibility on a mac or iphone, to weekly automatically save the content of that link, in a folder on my desktop?
    iv'e tried automator, but i dont succeed.
    Here by an example of the link.
    http://download.streampower.be/vrt/radio1/11_11ctwo-snip_med.mp3
    Please can somebody help me?
    Kind Regards
    K

    Copy ALL of this into a plain text editor:
    #! /bin/bash
    #replace everthing after 'curl' and before '>' with the url you want to use
    curl http://download.streampower.be/vrt/radio1/11_11ctwo-snip_med.mp3 > ~/Desktop/"$(date)".mp3
    Save it on your desktop as 'MP3_weekly_download'.
    In terminal, paste
    chmod 755 ~/Desktop/MP3_weekly_download
    then press 'return' on your keyboard.
    Test the script by double clicking on it on the desktop. It should open a Terminal window with a progress meter, and you should see the file in the link appear on your desktop with a timestamp as part of the filename.
    ⦿ If it doesn't work, you either didn't do one of the steps above correctly or copying the text above introduced some invisible return characters. If that's the case, open the text editor again and delete all the space between the lines, then put them back in by hitting the return key.
    Once you've got the script running all you have to do now is schedule it. You can do that in Automator or iCal. If you're not sure how, consult step 4 in this post:
    http://mac.tutsplus.com/tutorials/automation/4-easy-ways-to-automate-your-macs-s chedule/
    ps. Don't forget to replace the URL in the script with the one that you actually want to use, if that's not it.

  • Is this feasible with Applescript?

    I'm trying to figure out how to make the following happen for a law firm. I describe it in a short version, and then detail it in a long version.
    I'm told that Hazel nor Automator isn't really the solution.
    And if applescript is the best solution, then the next question is, where is a recommended place for me to do some "dummies" courses in learning Applescript?
    Short version:
    A Law firm would like to basically input a small set of data, such as a new Client's name and relevant contact details, and have a folder generated that includes subfolders. Inside the subfolders would be sets of documents that are automatically used with every new client, such as letter of introduction, contract, probate, will, etc. Ideally there would also be a step-by-step checklist generated with each client.
    Long version (my initial design document):
    ESTATE PLANNING
    FOLDERSNew Client Folders
    Client Documents
    Correspondence
    Estate Planning DocumentsSignatures
    Attorney Notes
    Funding
    Grant Deed(s)
    Preliminary Change of Ownership Form
    Letters to Financial Institutions
    COMMON LETTERSConcept: Type in certain data which would generate following:
    Engagement Letter – Hires Law Firm
    Funding Letter – What is missing or needed
    Closing Letter
    Trust Administration Letter
    Email Introducing Firm & Attachment (Indiv/Partnered/Married)
    Email – Closing Letter
    PROBATE
    FOLDERSNew Client Folders
    Client Documents
    Correspondence
    Pleadings
    Attorney Notes
    Discovery
    COMMON LETTERSConcept: Type in certain data which would generate following:
    Engagement Letter – Hires Law Firm
    Closing Letter
    (Other letters?)
    LITIGATION
    FOLDERS
    New Client Folders
    Client Documents
    Correspondence
    Pleadings
    Attorney Notes
    Discovery
    COMMON LETTERS
    Concept: Type in certain data which would generate following:
    Engagement Letter – Hires Law Firm
    Closing Letter
    (Other letters?)
    GENERAL CONSIDERATIONS
    1.  Process should include detailed checklist for each major area – EP, PRO, LIT;

    So you're looking for some help writing (part of) a software package that caters to the practice of law?
    These packages have been written before.  If you don't use one or customize one of the existing packages, then spend the time to look and see what the packages provide and (where that's available) how.
    LawStream and Desk Space Attorney are two that showed up in a quick search, and Firm Manager is cloud-based with OS X connectivity, and it is quite certain that there are other local and hosted packages for legal practices available.
    Or yes, you can roll your own customized legal practice package.  I probably wouldn't touch AppleScript here for much, if you're going to get paid to create a custom solution.  I'd probably using some combination of Python and bash for scripting, and Objective-C and Cocoa for applications, and probably some bridging, depending on what you're doing.  Ways to send mail and log calendar events from Python and Objective-C code do exist, too.
    For a full-on practice-management package, you're heading toward the creation of a state table (to control the sequencing that's typical here, do this task, then log that, fill those document fields from that document, then do whatever else, suggest some considerations to the attorney or the clerk based on the context, then generate an entry for the bill; that sort of thing), a document revision management system (for the masters and for the copies sent to the clients), the usual connections to mail and calendar, a mail-merge package to insert the changes from the customer database into the master copies of the documents, an audit trail both for accountability and billing, and a document store.  Using a directory tree would be an obvious approach for a simple implementation, but that doesn't tend to scale all that well; using a database or potentially a source code control package such as Mercurial (Hg) or git would be more typical.
    In general, AppleScript would not be my choice of implementation language here; not for something a practice was going to depend on.  There might well be cases where AppleScript would be useful and would be part of the solution, but GUI scripting isn't the most robust long-term approach for an application.  And there are other tools that can sequence stuff.  Could you generate a set of directories pre-populated with master copies of documents with an AppleScript script?  Sure...  A bash shell script or a Python script, ObjC, or most other languages could manage this, too.

  • [Solved] How to disable vim filetype indentation.

    Hello. I want to start using vim, but there is only that problem with that. In gedit I always use tabs 4 spaces wide for indentation, and I want to do something similar in vim. So in my .vimrc I used tabstop=4 and set autoindent. If I write a plain text file, it works correctly, for example, if I press tab in a new line, and the press enter, the following lines preserve the tab as indentation.
    The problem starts when writing code in common lisp or python. In lisp tab is replaced by two spaces and does some weird things, and in python tab is replaced by 4 spaces. I tried including "filetype indent off" in my vimrc, or writing ":filetype indent off" directly in console, but that doesn't have any effect. The only thing that somewhat works is to disable autodinent, but then I have to manually indent every line. What can I do?
    Last edited by Serge2702 (2014-11-06 20:57:54)

    I keep a skeleton vimrc file to use when I have a question similar to Serge2702's.  My barebones.vim:
    set nocompatible
    filetype plugin on
    set t_co=256 " Optional, you may comment this out.
    syntax on
    Start vim, using the alternate vimrc file with the command, say, for a lisp file: vim -u barebones.vim file_to_edit.lisp.
    Seems most filetypes default to a tab with a width of eight spaces here.  To see the tabs, you can use these two commands from within vim:
    :set list
    :set listchars=tab:_T
    Then you can try all the different setting combinations to figure out a comfortable tab width.
    And there are quite a few settings that affect the width of tabs and indentation besides tabstop. There's autoindent to repeat the previous line's indentation, but this is modified if you use cindent or smartindent to set the indent according to syntax. Then there are the expandtab and smarttab settings to use spaces for tabs, and shiftwidth and softtabstop also set indentation width. I don't see why anyone has trouble figuring it out.;)

Maybe you are looking for

  • How to create WEB  SERVICE in SAP

    Hi guys , i am new to WEB SERVICE IN ABAP.what's the purpose of web service ? can anyone give me step by step example to create web service in SAP? ur answers will be rewarded. Regards pabitra

  • V V V V Urgent; User asked for F-02 and F-43 Text FIeld mondatory.

    Dear SAP Gurus Please Suggest me how should i make Test field as mondatory field in F-02 and F-43 T codes, As i searched in the Internet saying go for Validation i have tried it but no Output. Now just i would to ask you whetheri should go for Ob41 P

  • DNG Converter Only Converts Part of .CR2 File

    I have tried converting in Photoshop CS4, Lightroom 2.6 and through the DNG Converter, but all have the same result. The image was taken with a Canon 7D, copied to the computer (running Windows 7 Ultimate 64-bit), converted to DNG with the original R

  • All the text is replaced by squares. Where have the fonts gone?

    When I open certain pages through Firefox, All the text is replaced by blank squares. Firefox is looking for the fonts, but can not find them. Can you help?

  • Using Introspection to Automate Persistence of Controls

    So far, in my researches, it is demonstrated that one is able to enumerate the controls (e.g. datgrid, checkbox) of a container.  Some of the controls turn up missing if they are inside an unexposed accordion fold.  My task is to find a way to persis