Saturday, March 23, 2019

#1 2019-03-08 01:42:26 pm

Titanium
Member
From:: ~/Desktop
Registered: 2005-08-22
Posts: 54
Website

Simulate the Enter key

Hello,

I want run the following command:

sudo sysdiagnose -v

From the Terminal, it's necessary to press Enter.

In do shell script a message appears:
Triggering sysdiagnose programmatically from CLI with incorrect arguments. Exiting.

Is it possible to simulate the Enter key to run this command in do shell script ?

do shell script "sysdiagnose -v" with administrator privileges

Thanks.


iMac 27" 3,4 Ghz - MacOS Mojave
https://www.titanium-software.fr

Offline

 

#2 2019-03-13 08:29:19 am

FredrikM
Member
From:: Förslöv, Sweden
Registered: 2019-02-19
Posts: 15

Re: Simulate the Enter key

If you don't mind that the terminal window is showing you could use something like this.

Applescript:


tell application "Terminal"
   activate
   set scriptOne to "sudo sysdiagnose -v"
   set scriptTwo to "-my password-"
   tell application "System Events" to keystroke scriptOne & return
   delay 1
   tell application "System Events" to keystroke scriptTwo & return
   delay 1
   tell application "System Events" to keystroke return
end tell

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)