Osascript quoting issue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Osascript quoting issue
# 1  
Old 11-09-2012
Osascript quoting issue

I am at a loss on this one. I am trying to run this command on a bunch of (OS 10.7.4) macs:
Code:
osascript -e "tell application \"System Events\" to return name of every process whose frontmost is true"

On some, it works fine. On others, I get this error:
Quote:
57:64: syntax error: Expected class name but found identifier. (-2741)
I have also tried (note the single quotes):
Code:
osascript -e 'tell application "System Events" to return name of every process whose frontmost is true'

but I get the same error. What am I missing? Why does this work on some machines and not others?

Last edited by nextyoyoma; 11-09-2012 at 01:19 PM.. Reason: correct typo in single quote example.
# 2  
Old 11-09-2012
You are missing a strong quote at the beginning of your statement.
Code:
osascript -e 'tell application "System Events" to return name of every process whose frontmost is true'
             ^*****

# 3  
Old 11-09-2012
Quote:
Originally Posted by xbin
You missing a strong quote at the beginning of your statement.
Code:
osascript -e 'tell application "System Events" to return name of every process whose frontmost is true'
             ^*****

Actually that's a typo. Sorry. It doesn't work with strong quotes either.

---------- Post updated at 02:27 PM ---------- Previous update was at 01:18 PM ----------

Ok, it looks like it just wasn't working over SSH. What I was actually trying to do was have a little background app pull commands from a mysql database and run them, but something about the formatting must get changed when pulling the command that way, because it fails to run on some machines. I ended up just storing the command within the app and it seems to work fine.
# 4  
Old 11-10-2012
The following forms work for me (local machine running 10.8.1, remote machine running 10.5.8):

Code:
ssh MYSERVERNAME "osascript -e 'tell application \"System Events\" to return name of every process whose frontmost is true'"

ssh MYSERVERNAME 'osascript -e "tell application \"System Events\" to return name of every process whose frontmost is true"'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with Bash quoting

I am trying to write a BASH script that will prompt a user to enter a number of days, then calculate the date. My problem is the date command uses single or double quotes. For Example.. date -d "7 days" Here is an example of some same code I am trying to work through. echo "when do you... (4 Replies)
Discussion started by: javajockey
4 Replies

2. Shell Programming and Scripting

Quoting the values in second field

Hi, I have got a file comp_data containing the below data : 38232836|9302392|49 39203827|8203203,3933203|52 72832788|567,3245,2434324|100 This file can have many rows like shown above. I want the values separated by "," in second column(taking "|" as delimiter) to be in quotes. These... (2 Replies)
Discussion started by: msabhi
2 Replies

3. Shell Programming and Scripting

quoting hell - help needed!!

I am writing a bash script to automate the installation of web environment on a base install of Fedora. And I'm at the limit of my last nerve and my bash skills. My brain is screaming at me: "Give up and use perl", but I am trying to stick to bash since the script will modify the perl environment... (6 Replies)
Discussion started by: lbe
6 Replies

4. Shell Programming and Scripting

quoting just selected words

Hi all, i have a file that looks like: one:two:three:four:five six:seven:eight:nine:ten and i'd like to quote the fourth column, getting: one:two:three:"four":five six:seven:eight:"nine":ten i was thinking something like: awk 'BEGIN{FS=":"}{print $1 FS $2 FS $3 FS \"$4\" FS $5}'... (5 Replies)
Discussion started by: Dedalus
5 Replies

5. Shell Programming and Scripting

Quoting issue: Trouble with bash strings in script

I can do this on the command line: sqsh -S 192.168.x.x -o tmp -U user -P fakepass -D horizon -C "\ select second_id from borrower where btype like '%wsd%' " I can also just leave the SQL at the end intact on one line .... ... However, when I throw this in a script like: $SQSH -o... (4 Replies)
Discussion started by: Bubnoff
4 Replies

6. Shell Programming and Scripting

Quoting Characters

I have this data how do i add ' ' to them like '-AAL00L' , '-BBE4577' , 'ABC' -AAL00L -BBE4577 ABC (5 Replies)
Discussion started by: dinjo_jo
5 Replies

7. Shell Programming and Scripting

quoting question

hi guys, i have a question related to quoting but i am not sure how to formulate it... lets say we want to simulate the following shell actions cd ~/project-dir ctags /home/work/folder1/*.sh /home/work/folder2/*.sh /home/work/folder3/*.sh so i make the following script buidtags.sh ... (2 Replies)
Discussion started by: aegis
2 Replies

8. Shell Programming and Scripting

*.pm globs without quoting, *.pl doesn't.

Can someone explain the following? I can use find on *.pm without quotes, but find on *.pl makes on error, I need quotes for the second version. What's up with that? $find -name *.pm ./tieProxyStatus/Status.pm $find -name *.pl find: paths must precede expression Usage: find $find... (2 Replies)
Discussion started by: tphyahoo
2 Replies

9. Shell Programming and Scripting

M4 quoting drives me crazy

Hi, I have trouble with quotations of the M4 preprocessor. I want to write a basic makro that removes all spaces and newlines at the end and at the beginning of a string. I tried this: define(`TRIM_END', `patsubst(`$1', `\(\\n\| \)*$', `')') define(`TRIM', `patsubst(`TRIM_END(`$1')',... (0 Replies)
Discussion started by: hindman
0 Replies

10. UNIX for Dummies Questions & Answers

Wildcards and quoting

Hi All In a script, I want a user to enter 4 characters, these can be a mix of letters (uppercase and lowercase) and numbers. In this example $var represents what the user has entered. eg $var can be A9xZ, 3DDL, bbHp .........etc I need to check that the user has only entered characters... (2 Replies)
Discussion started by: Bab00shka
2 Replies
Login or Register to Ask a Question