• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: sudo permission in a script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sudo permission in a script


  • Subject: Re: sudo permission in a script
  • From: Omar K N <email@hidden>
  • Date: Wed, 17 Sep 2014 17:14:47 +0200

Hi Yvan,

The shell script is part of an AppleScript, so as it is now I can’t use it because I don’t know how to write the sudo in it:
If I write sudo do shell script "echo " & (quoted form of ExportList) & "|tr -d \"\\t\"|/usr/local/bin/dayone/dayone new"
the process will stop.

How can this be avoided?

with best regards,
Omar K N
Stockholm, Sweden

--------------------------------..————————————————
// MAIN PROGRAM
======================================
*)

tell application "OmniFocus"

    --SET THE REPORT TITLE
    set ExportList to (current date) & return & return & "Completed Projects in the Last Day" & return & "---" & return & return as Unicode text

    --PROCESS THE PROJECTS
    tell default document

        set refFolders to a reference to (flattened folders where hidden is false)
        repeat with idFolder in (id of refFolders) as list
            set oFolder to folder id idFolder
            set ExportList to ExportList & my IndentAndProjects(oFolder) & return
        end repeat

        --ASSEMBLE THE COMPLETED TASK LIST
        set ExportList to ExportList & return & return & "Tasks Completed in the last day" & return & "---" & return & return & return
        set day_ago to (current date) - 1 * days
        set refDoneInLastWeek to a reference to (flattened tasks where (completion date ≥ day_ago))
        set {lstName, lstContext, lstProject, lstDate} to {name, name of its context, name of its containing project, completion date} of refDoneInLastWeek
        set strText to ""
        repeat with iTask from 1 to length of lstName
            set {strName, varContext, varProject, varDate} to {item iTask of lstName, item iTask of lstContext, item iTask of lstProject, item iTask of lstDate}
            if varDate is not missing value then set strText to strText & short date string of varDate & " - "
            if varProject is not missing value then set strText to strText & " [" & varProject & "] - "
            set strText to strText & strName
            if varContext is not missing value then set strText to strText & " *@" & varContext & "*"
            set strText to strText & "  " & return
        end repeat
    end tell

    set ExportList to ExportList & strText as Unicode text

    -- Modify "/usr/local/bin/dayone/dayone" to "/usr/local/bin/dayone" if you didn't screw it up like I did.
    do shell script "echo " & (quoted form of ExportList) & "|tr -d \"\\t\"|/usr/local/bin/dayone/dayone new"

end tell

(*
======================================
// MAIN HANDLER SUBROUTINES
======================================
*)

on IndentAndProjects(oFolder)
    tell application id "OFOC"

        set {dlm, my text item delimiters} to {my text item delimiters, return & return}
        set day_ago to (current date) - 1 * days
        set strCompleted to (name of (projects of oFolder where its status is done and completion date ≥ day_ago)) as string

        set my text item delimiters to dlm

        return strCompleted & return
    end tell
end IndentAndProjects





On 17 Sep 2014, at 17:02, email@hidden wrote:

From: "koenig.yvan" <email@hidden>
To: liste AppleScript US <email@hidden>
Subject: Re: sudo permission in a script
Message-ID: <email@hidden" style="font-family: LucidaGrande; font-size: 18px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">email@hidden>
Content-Type: text/plain; charset="iso-8859-1"


Le 17/sept./2014 à 16:53, okn <email@hidden> a écrit :


Hi & good day,

How to run a shell in a script when the sudo permission is needed?

It would be awkward to have to give the permission every time.


This is the script:

Omnifocus to Day One daily log of completed tasks

http://jeredb.com/omnifocus-to-day-one-daily-log-of-completed-tasks

and here is the command line:

ln -s "/Applications/Day One/Day One.app/Contents/MacOS/dayone" /usr/local/bin/dayone


The official scheme is :

do shell script <your Unix command line> with administrator privileges


Yvan KOENIG (VALLAURIS, France) mercredi 17 septembre 2014 17:02:13



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: sudo permission in a script
      • From: "koenig.yvan" <email@hidden>
    • Re: sudo permission in a script
      • From: Kevin Meaney <email@hidden>
  • Prev by Date: Re: sudo permission in a script
  • Next by Date: Re: sudo permission in a script
  • Previous by thread: Re: sudo permission in a script
  • Next by thread: Re: sudo permission in a script
  • Index(es):
    • Date
    • Thread