Menu

Scripts to start/stop Ink2text+SHIP

Help
Anjishnu
2011-06-28
2014-04-25
  • Anjishnu

    Anjishnu - 2011-06-28

    Copy and save the two codes below by the name "ink2text-start.sh" and "ink2text-end.sh" respectively.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    #!/bin/bash
    ## ink2text-start.sh script
    InstallDir=/usr/local/share/ship/client
    JarFile=SHIP_Ink2Text_v1.1.0.jar
    ClientPIDFile="$HOME"/.ship-pid
    Ink2TextLockFile="$HOME"/.ink2text-lock
    ## Check for ink2text lock file
    if [ -f "$Ink2TextLockFile" ];then
    #     echo "Ink2text already running. Aborting."
        zenity --info --text "Ink2text already running. Aborting.
    However if you think it is not, wait for 10-15s, run the
    \"ink2text-end.sh\" script and then run this script once more." &
        exit 0
    else
    ## Create ink2text lock file
        touch "$Ink2TextLockFile"
    fi
    while (true)
    do
        if [ -f "$ClientPIDFile" ];then
            ## If ship-pid file is found, then check whether ship is running
            ## or not
            ClientPID=$(cat "$ClientPIDFile")
            ClientRun=$(ps -A | grep "$ClientPID")
            RecogServer=$(pgrep RecognitionServ)
            if [ -z "$ClientRun" ];then
                ## If SHIP client is NOT running then kill the server
                pkill RecognitionServ
                rm -f "$ClientPIDFile"
                rm -f "$Ink2TextLockFile"
                exit 0
            fi
        else
            ## If ship-pid file is not found, then start server and client
            echo "Starting recognition server"
            ## Start RecognitionServer
            export WINEPREFIX="$HOME"/.wine-Ink2Text
            wine /usr/local/bin/RecognitionServer.exe 8888 &
            sleep 1s
            ## Start ship-client
            cd "$InstallDir"
            echo "Starting SHIP client"
            alltray java -Djava.library.path=/usr/lib/jni -Dswing.aatext=true \
                -jar "$JarFile" ship.properties &
            sleep 1s
            ShipClientPID=$(pgrep -n java)
            echo "$ShipClientPID" > "$ClientPIDFile"
        fi
        sleep 3s
    done
    

    Ink2text-end script

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    #!/bin/bash
    ## ink2text-end.sh script
    ClientPIDFile="$HOME"/.ship-pid
    Ink2TextLockFile="$HOME"/.ink2text-lock
    pkill ink2text-start.sh
    rm -f "$Ink2TextLockFile"
    pkill RecognitionServ
    if [ -f "$ClientPIDFile" ];then
        ClientPID=$(cat "$ClientPIDFile")
        kill -9 "$ClientPID"
    fi
    

    After saving the above codes make them executable and copy them in your PATH

    chmod +x ink2text-start.sh
    chmod +x ink2text-end.sh
    sudo cp ink2text-start.sh /usr/local/bin/
    sudo cp ink2text-end.sh /usr/local/bin/
    

    To start the Ink2text server and run the SHIP client, run the command

    ink2text-start.sh
    

    To close the server and client, run the command

    ink2text-end.sh
    
     
  • Jack

    Jack - 2014-04-25

    The start.sh script isn't working for me. Terminal spits back an error:

    ink2text-start.sh: 20: ink2text-start.sh: Syntax error: "then" unexpected (expecting "done")

    Any idea what's up? It also looks like the single ampersands don't register either. I've made each of them "&&" instead and I don't get errors anymore.

     

Log in to post a comment.