Sudo command in apple script? Encrypting apple script?
Hi,
1. I need a way to enter my root user password in applescript (when you run sudo in terminal you are prompted for a password, this is not so in apple script. So how do you tell apple script what the password is?)
2. Can i encrypt my applescript with a password so that only i can open it?
Thanks,
Patrick.
# 2 works great, #1 not so much... ive been trying
tell application "Terminal"
do shell script "su"
end script
any way i can auto enter my password following "do ....Su"?
Similar Messages
-
So I created a simple bash script to run on login.....
one of the commands is the following:
sudo "something something something"....
One thing I haven't learned in my years of Unix is how do you get a bash script to run a sudo command without having to enter a password? I know this is trival, but just a quick 'this is how you do it' would be cool.
Thanks ahead of time on this really dumb question.There's a few ways to do this. Here's two (pick the method you like):
Method 1: Using "askpass".
With this you always do sudo -A command. The -A argument tells sudo to execute a command that echos the password to stdout. That command is something you write. For this explaination let's call the command pw and stick it /usr/local/bin. So it's full pathname would be /usr/local/bin/pw.
sudo -A can get the pathname to pw a number of ways.
1. From the sudoers file.
Use visudo to add the following line to the sudoers file:
Defaults:ALL askpass=/usr/local/bin/pw
2. Using the SUDO_ASKPASS environment variable.
export SUDO_ASKPASS=/usr/local/bin/pw
This might work too (assuming SUDO_ASKPASS has been previously exported):
SUDO_ASKPASS=/usr/local/bin/pw sudo -A command
Method 2: Have sudo read the password from stdin
echo -n password | sudo -S command
The -S option tells sudo to read the password from stdin so echo pipes it in (without the ending newline).
The only relatively secure scheme of these two methods is the askpass (-A) method. At least with that method you have a chance of encrypting/hiding your password down in the command that echoes it to stdout. The -S method would contain your password explicitly in a script somewhere unless you make other provisions to encrypt/hide it with that technique. -
I am trying to update my iTunes to 10.5.1 so that I can upgrade my 3GS phone but am getting the following error message when trying to install the itunes: Install step failed: Run pre upgrade script for apple mobile device support. Contact software manufacturer for assistance. I am on a MacBook pro running 10.5.8 OS. Has anyone seen this before and how can I get it resolved.
Thanks for your help in advance....Did you ever figure out the problem? "Contact Software Manufacturer"?? That sounds ominous... I've got the same issue and I'm pretty durn aggravated right about now....
Thanks! -
Problem running sudo command in script
Hello,
I try to run this script.
#!/bin/bash
sudo /bin/cat /dev/input/event1 >> /home/tom/.log/log.bin &
The sudoers entry
%users ALL= NOPASSWD: /bin/cat /dev/input/event1 >> /home/tom/.log/log.bin
I get the following error!
$ Passwort: sudo: pam_authenticate: Kommunikationsfehler
Kommunikationsfehler = eng: communication error
What's wrong with that?
Thank you!
clementisSorry, for being not precise.
I created the alias in .bashrc in my $home directory. In sudoers all users are allowed to key in this command without a passwort entry.
I know how to autostart in xfce and so created an autostart entry but unfortunatly it doesn't work for my "special" command.
What I did:
1. I wrote a script (first post) and tried to autostart it in xfce. For that command I created an entry in sudoers in order to avoid enter root passwort. The script didn't start.
Then...
2. I created an autostart entry (deleted the first one - see point 1) and entered the whole command (cat .../event1 >> $home...) in the xfce autostart input window. The idea was to run the command directly and not through a script. But it didn't work.
Therefore I tried to run alter the command to "bash cat .../event1 >> $home ...." Didn't work either.
3. I also deleted the autostart entry no 2. and created the alias in .bashrc in my home directory. Now created a new autostart entry trying to start the alias. Didn't work.
I also tried to set the Terminal option in the file $home/.config/autostart/log.desktop to "true".
So it looked like this:
[Desktop Entry]
Encoding=UTF-8
Version=0.9.4
Type=Application
Name=log
Comment=event1
Exec= sudo cat /dev/input/event1 >> /home/tom/.cblog/log.bin &
StartupNotify=false
Terminal=true
Hidden=false
The alias for example works well if I enter it in xterm.
So, I don't know why it isn't working! :-(
Thank you for any help
Clementis -
I have an older Macbook with OS/X. Tried to download iTunes 10 a few times now, but when installing I always get the same error message: Run Preinstall Script for Apple Mobile Device Support. What can I do to finalise the installation?
Thanks. Short of the sort of "generic" suggestions of restaring your system, if you haven't, and repairing disk permissions and verifying the disk, I don't have any advice right now. I'll do some research and see if I can come across anything. Meanwhile, someone else may have an idea.
Regards. -
Hi I'm not able to upgrade my Mac OS X 10.5.8 to itunes 10.5 Keep getting message "the following install failed. run pre upgrade script for apple mobile device support" contact software manufacture for assistance. any help please?
Did you ever figure out the problem? "Contact Software Manufacturer"?? That sounds ominous... I've got the same issue and I'm pretty durn aggravated right about now....
Thanks! -
Its possible to convert Apple script to Java script
Hi,
Please Help me anyone to do that script.
its possible to convert below mentioned Apple script to Java Script.
Thanks in advance.
Help me......!
-yajiv
Code:
tell me to addImageLabels()
on addImageLabels()
tell application "Adobe InDesign CS5"
set numberAdded to 0
activate
set enable redraw of script preferences to true
set currentFonts to (get name of every font)
if currentFonts does not contain fontname then
display dialog "The font \"" & fontname & "\" is not active on your system." buttons {"Continue anyway", "Cancel"} default button 2
end if
tell document 1
-- get a list of unique page IDs in this document
set allpageids to my getPageIds()
repeat with p from 1 to (length of allpageids)
set pgid to item p of allpageids
-- loop through these, getting a list of unique page item IDs to inspect
tell page id pgid
set pageitems to (get id of every page item)
repeat with i from 1 to (length of pageitems)
set pid to item i of pageitems
tell page item id pid
try
-- certain boxes will fail to yield a content type, whatever
if content type is graphic type then
set c to class
set i to id
-- get the name of the link, i.e. the filename, subject to labelFormat (full name, first six chars, etc.)
set gn to my getImageName(pgid, c, i)
if (gn is not "Empty") and (gn is not "") then
set b to visible bounds
set h to (item 3 of b) - (item 1 of b)
set newtop to (item 1 of b) + (h / 2)
set item 1 of b to newtop
set w to (item 4 of b) - (item 2 of b)
if w < minwidth then
set item 4 of b to ((item 4 of b) + 0.2)
set item 2 of b to ((item 2 of b) - 0.2)
end if
set l to (make new text frame at beginning of page id pgid with properties {visible bounds:b, fill color:fillcolor, contents:gn, label:"imagelabel"})
tell l
tell paragraph 1
set justification to center align
try
set applied font to fontname
end try
set point size to fontsize
set fill color to textcolor
end tell
set inset spacing of text frame preferences to ((insetspacing as string) & " in") as string
fit given frame to content
set numberAdded to numberAdded + 1
end tell
end if
end if
end try
end tell
end repeat
end tell
end repeat -- allpageids
end tell -- document 1
display dialog "Added " & numberAdded & " labels." buttons {okButton} default button 1 giving up after 10 with title scriptName
end tell -- InDesign
end addImageLabels
on getPageIds()
tell application "Adobe InDesign CS5"
tell document 1
tell master spread 1
set masterpageids to (get id of every page)
end tell
set docpageids to (get id of every page)
end tell
end tell
return masterpageids & docpageids
end getPageIds
on getImageName(int1, cla1, int2)
tell application "Adobe InDesign CS5"
tell document 1
tell page id int1
if cla1 is rectangle then
set imagename to (name of item link of graphic 1 of rectangle id int2)
else if cla1 is polygon then
set imagename to (name of item link of graphic 1 of polygon id int2)
else
return "Unknown"
end if
try
if (labelformat is "First six characters") then
return (characters 1 thru 6 of imagename) as string
else if (labelformat is "Base name of linked file") then
set op to offset of "." in imagename
return (characters 1 thru (op - 1)) of imagename as string
else
return imagename
end if
on error
return "Empty"
end try
end tell
end tell
end tell
end getImageNameYajiv:
I realize English is probably not your first language, but you are not really making sense. Perhaps you could use more words and write in more detail.
It seems you already have your script in AppleScript. Why do you need to convert it to JavaScript?
It's going to be inconvenient at best and probably not worth anyone's time.
Just use the AppleScript. -
What is "run pregrade script for apple devices"?
What is "Run pregade script for Apple Device mean. I am tryong to down load Itunes 10.5 on my 2005 Mac. What is the problem?
Are you sure that's how the error message is phrased? Are you sure it doesn't actually say "run preupgrade script for Apple Mobile Device Support"? (note in particular the difference between "preupgrade" and "pregrade" as you have phrased it)
If it really does instead say "preupgrade", not "pregrade", here are a couple of threads with suggestions:
https://discussions.apple.com/thread/3373568?start=0&tstart=0
https://discussions.apple.com/thread/2515630?start=0&tstart=0
If those don't help, this support article may:
http://support.apple.com/kb/HT1747
Regards. -
Cannot upgrade my iTunes to version 10.4.1---get message---The following install step failed: runupgrade script for Apple mobile device support.--Contact softwae=re manufacturer for assistance.
Can someone help me?
Thank you.
Geraldme too did you get any help?
-
Cannot upgrade my iTunes to version 10.4.1---get message---The following install step failed: runupgrade script for Apple mobile device support.--Contact softwae=re manufacturer for assistance.
Can someone help me?
Thank you.
Geraldme too did you get any help?
-
Hi All ,
In my environment we are having exchange 2013 enterprise edition with SP1 which is installed in windows server 2012 standard edition.
We have enabled mailbox auditing for few mailboxes and also we have made simple powershell script with only the below mentioned commands .when i run the ps1 script in exchange management shell ,i can able to get the relevant output.
CMDLETS in powershell script :
Search-MailboxAuditLog -StartDate ((Get-Date).AddHours(-24)) -EndDate (Get-Date) -showdetails | fl >e:\output.txt
Note : we are having only the above commands in ps1 script , apart from that we don't have anything in it .
Sametime i have scheduled the same powershell script via task scheduler .But i cannot able to get the valid output ,instead of that i was getting a blank output file with no data in it .
Steps handled on my side to run the powershell script in task scheduler:
1.when i remove the parameter showdetails in the ps1 script ,i can able to get the output in the txt file .But in my scenario showdetails is the only parameter which will brought me more and in depth details about mailbox auditing.
The Difference what i have seen between exchange 2010 and exchange 2013
when in run the same powershell script via task scheduler in exchange 2010 enterprise environment installed in windows server 2008 r2 enterprise OS, i can able able to get the proper output without removing the showdetails parameter .
I am using the below methods to run the ps1 file via task scheduler in exchange 2013 environment .
program/script : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Add arguments : -PSConsoleFile "E:\Program Files\Microsoft\Exchange Server\V15\Bin\exshell.psc1" -Command ". 'C:\scripts\MailboxAuditReport\test.ps1'"
I have mentioned the error below and that is the one what i have faced, when i try to run the PS1 script directly in windows powershell and not in exchange management shell .
Error message : "the requesting account does not have permission to access the audit log"
Please help me out to resolve this case .
Thanks
S.NithyanandhamHi All ,
In my environment we are having exchange 2013 enterprise edition with SP1 which is installed in windows server 2012 standard edition.
We have enabled mailbox auditing for few mailboxes and also we have made simple powershell script with only the below mentioned commands .when i run the ps1 script in
exchange management shell,i can able to get the relevant output.
CMDLETS in powershell script :
Search-MailboxAuditLog -StartDate ((Get-Date).AddHours(-24)) -EndDate (Get-Date) -showdetails | fl >e:\output.txt
Note : we are having only the above commands in ps1
script , apart from that we don't have anything in it .
In case, if i have scheduled the same powershell script via task scheduler .But i cannot able to get the valid output ,instead of that i was getting a blank output file with no data in it .
Steps
handled on my side to run the powershell script in task scheduler:
1.when i remove the parameter showdetails
in the ps1 script ,i can able to get the output in the txt file .But in my scenario showdetails is the only parameter which will brought me more and in depth details about mailbox auditing.
The
Difference what i have seen between exchange 2010 and exchange 2013
when in run the same powershell script via task scheduler in exchange 2010 enterprise environment installed in windows server 2008 r2 enterprise OS, i can able able to get the proper output without removing the showdetails parameter .
I
am using the below methods to run the ps1 file via task scheduler in exchange 2013 environment .
program/script : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Add arguments : -PSConsoleFile "E:\Program
Files\Microsoft\Exchange Server\V15\Bin\exshell.psc1" -Command ". 'C:\scripts\MailboxAuditReport\test.ps1'"
I have mentioned the error below and that is the one what i have faced, when i try to run the PS1 script directly in windows powershell and not in exchange management shell .
Error message : "the requesting account does
not have permission to access the audit log"
Please help me out to resolve this case .
Thanks
S.Nithyanandham -
I am using Photoshop CC2014 15.00. In the pop-up menu for the Fill command there is a place for Scripted patterns. Within that part, the tree and the picture frame are grayed.
Why? I've seen demonstrations on how to use the feature but mine doesn't work. I checked the updates and I have the current version.
Thanks. LMI am running CC 2014.2.1 and I've updated to Yosemite. Not seeing tree or frame as an option in the menu. Coworker still on Mavericks has it.
-
Applescript for running sudo commands in terminal
I'm a newbie when it comes to Applescript and was wondering if someone could help with a basic request. I need to write a small script to do the following:
1. Launch terminal
2. Run the 'Sudo -s' command
3. Enter the administrator password (in plain text)
and then
4. run some sudo commands like "sudo defaults write /Library/Preferences/com.apple.loginwindow HiddenUsersList -array-add administrator"
I actually WANT the administrator password to be in the script in plain text even though I understand the security risks (I will literally be the only person to ever see the script). I've trawled forums all over but can't seem to find what I am looking for and cannot get it working by patching together the various commands I have found. Thanks in advance for any help you can give!
SeanI've included two examples. The preferred way & the hacker way.
with administrator
It is easier to diagnose problems with debug information. I suggest adding log statements to your script to see what is going on. Here is an example.
Author: rccharles
For testing, run in the Script Editor.
1) Click on the Event Log tab to see the output from the log statement
2) Click on Run
For running shell commands see:
http://developer.apple.com/mac/library/technotes/tn2002/tn2065.html
on run
-- Write a message into the event log.
log " --- Starting on " & ((current date) as string) & " --- "
-- debug lines
set unixDesktopPath to POSIX path of "/System/Library/User Template/"
log "unixDesktopPath = " & unixDesktopPath
set quotedUnixDesktopPath to quoted form of unixDesktopPath
log "quoted form is " & quotedUnixDesktopPath
try
set fromUnix to do shell script "sudo ls -l " & quotedUnixDesktopPath with administrator privileges
display dialog "ls -l of " & quotedUnixDesktopPath & return & fromUnix
on error errMsg
log "ls -l error..." & errMsg
end try
end run
This version has an inline password.
Notice the echo 'password' |
The single quotes are no accident.
It is easier to diagnose problems with debug information. I suggest adding log statements to your script to see what is going on. Here is an example.
Author: rccharles
For testing, run in the Script Editor.
1) Click on the Event Log tab to see the output from the log statement
2) Click on Run
For running shell commands see:
http://developer.apple.com/mac/library/technotes/tn2002/tn2065.html
on run
-- Write a message into the event log.
log " --- Starting on " & ((current date) as string) & " --- "
-- debug lines
set unixDesktopPath to POSIX path of "/System/Library/User Template/"
log "unixDesktopPath = " & unixDesktopPath
set quotedUnixDesktopPath to quoted form of unixDesktopPath
log "quoted form is " & quotedUnixDesktopPath
try
set fromUnix to do shell script "echo 'password' | sudo ls -l " & quotedUnixDesktopPath
display dialog "ls -l of " & quotedUnixDesktopPath & return & fromUnix
on error errMsg
log "ls -l error..." & errMsg
end try
end run -
Terminal automatically executes sudo command on opening?
I am running Lion 10.7.5. I tried to execute a sudo command but remembered i did not have sudo privleges on my account so i logged onto the root user and executed it there. Getting back on my regular account i opened terminal but it automatically executed the sudo command again and if i exceeded the password attemp limit it just re executed the command and looped infinently. I now cannot use terminal on my account. I have deleted com.apple.Terminal.plist from its location and still nothing.
Did you accidentally put a sudo command into one of the following files?
.bash_profile
.bash_login
.profile
.bashrc
Or does one of the above files run a script that tries to execute sudo?
If you cannot get a command prompt you can use Terminal -> Shell -> New Command to issue one command at a time.
Message was edited by: BobHarris -
Hijacked apple id through apple support profile!
unknown person(s) have hijacked my entire apple id! After some experimentation, i have regained some control back over it. although, I can not contact Apple support either through the internet or a phone call! Below, I will explain what I have found!
I have several apps that are either molissing or have been replaced, installed or missing. During my first post, then reply to that post, i found that my acct was being spoofed by a banned user, then I went to a clean safe computer to lookup my posts, since I could no longer seem to post anything here. I found that my iPhone was no longer registered under my name, called apple support, they reregistered my iPhone under my name! then sent me to discuss the icloud problem with a tech! After ten minutes of explaining my problem, I was suddenly cut off from that tech in the middle of his sentence and someone different came on the line! He did not even sound close to the other guy. I chose not to confront him and decided to look up the support issue on my support profile! That issue under my support profile claimed I did a self help for icloud problem, nothing about my transfer pending to apple security nor the reference numbe!
AT some point i realized that my Icloud info had changed, I started resetting things, erasing everything and resetting all my settings. Then i finally got a break, found 4 mailboxes in my mail named "icloud"!, i removed them, then deleted that icloud account. Many things worked out ok, but at this level I still notice two iCloud mails going into my inbox!
FRom what I have researched on the apps I am having problems with, two are logitate apple apps, but are setup in two different iCloud accts! I think that I know them, but might need apples help in finding each one. These hijackers have put apps and other corrupt software in my iPhones storage, I saw this early on, a message about what was stored in my iPhones storage. That software is either an early version of windows 95 or 98, but could also be the droid software I talked about!
these hijackers then try to hijack my iPhone by building a virtual pc and forcing me to complete an install under their corrupt software in my Iphones storage! While they might have a few holes to break into and have some strange software to do this, I am able to gain control once again by trial and error to get back to a more secure iCloud acct. I have caused quite a few of the apps they use in this to stop working for them and gained control of hhem once more! now I see this "bird" app installing and crashing again, it is some sort of tunnel system for sending files and messages through a tunnel (pipe?)
They have even corrupted Siri somehow or blocked Siri from finding this community, But Siri is pretty cool for an AI and she doesn't give up so easily! I still have to move up two levels before I can get this cleared up. it is like a house of cards, each level moved to will allow me to delete that icloud account and move to the next.
I am constantly deleting a chinese language backup, along with other apps and stored documents and data! Messenger is a major flaw, i can message myselfmeaning they can message myy iPhone through backgroung messaging and get right into my iPhone through the locks! then they use Siri and other supplied apps against me and my iphone! iBooks transfers the "cloud" sent mail to my iphone and hides those mailboxes in iCloud! Music might be spoofed and sends commands via the network of corrupt iCloud accts they build!
FYI: While my iOS is 64 bit, all of this corrupt software and additional builds os iOS are 32 bit! This hijack of theirs will not work without Java in the mix! It uses ax's, macros, scripts and plugins to do its job! They also need to use third party apps and OEM plugins, thats the reason for windows OS! Windows is the same design for many types of pc's while systems like Apple is for only one brand and is propoetary! While some of their plugins might work, most can and will fail! Besides the flaws they find to break into Apple's server, Apple software is still pretty rock solid! Not easily broken!
To any Apple Tech, please pass this onto an upper lever security tech and ask them to look into my apple id's. If I can find a way to contach the individual assigned to my case, I will do so... If not, please excust my posting here! I need to get into the next two iCloud accts if I can to close and remove items there before i can delete those iCloud accts, starting a new icloud acct will not work!
I remain open for suggestions from the community. Thanks...No one here has been rude. We have been direct. We have asked for clarification on a post that was not clear and was excessively emotional. I'm not sure how you can say you have exactly the same problem as this person (as well as the same problem as someone else in another thread) when this person never was able to clarify what problem they have.
If you want assistance, please explain what problems you are actually seeing on your phone, preferably in a new thread of your own. Don't jump to any conclusions about what caused them. Just describe what you have observed and what troubleshooting steps you have already taken.
For a start, have you restored the phone as new? If you have not ever jailbroken your phone (and usually even if you have), restoring it as new will return it to factory state and it will be fine.
Maybe you are looking for
-
Bridge(CS3) conflict with Windows file explorer
Bridge will crash on me at least twice a day. I use Bridge and Windows file explorer simultaneously copying and moving files across a network. When Bridge quits I sometimes lose my network connection and have a lot of trouble re-connecting. I have do
-
How can I load data with Scripts on *FDM* to a HFM target System????
Hi all! I need help because I can´t find a good guide about scripting on FDM. The problem I have is the next one. I have on mind to load my data with data load file in FDM to a HFM target system, but I would like to load an additional data using an e
-
Extraction, Flat File, Generic Data Source, Delta Initialization
Extraction, Flat File, Generic Data Source, Delta Initialization I have couple of questions regarding data extraction. 1. If you have Data Source a Flat File e.g. Excel file I know that you have to create Data Source at BW side. How do you upload
-
Itunes now says my iTouch is not authorized
Just went into iTunes to sync and t says computer not authorized, which it is. So I put in user name and password, and it says it already is (following this?), asks me to authorize again. A revolving door I can't get out of... Any ideas?
-
Reading the BR*Tools responses from a file
Hi, Can we keep all the responses for BRTools in a file & ask BRTools to read from it? We need this to perform the repetitive tasks. I have tried this. BR*Tools reads first few responses but give error u201CBR0255E Cannot read from standard inputu201