Register
It is currently Fri Nov 28, 2014 2:28 pm

"File ... wasn't found" error when using bash script


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Wed Sep 12, 2012 6:56 am   

Joined: Wed Sep 12, 2012 6:38 am
Posts: 1
I'm using Mountain Lion and I'm trying to write a script to resize windows from the terminal via osascript.
Here's the script I was using:

Quote:
osascript -e "tell application \"$appname\" to set bounds of windows whose visible is true to {$bounds}"


Problem is, I get a "File <$appname> wasn't found" error.
Same line of code works fine when I type it directly on the terminal or call it as a function from my .profile file, though.

Should I be using a different format when calling osascript from bash scripts?
Thanks.


Top
 Profile  
 PostPosted: Wed Sep 12, 2012 12:28 pm   
User avatar

Joined: Wed Jun 08, 2011 8:27 am
Posts: 189
Location: outer Shpongolia
merkuryo wrote:
Problem is, I get a "File <$appname> wasn't found" error.
Same line of code works fine when I type it directly on the terminal or call it as a function from my .profile file, though.

I think it's all about quotes, but since I don't have a Mac I can't play with your line.


merkuryo wrote:
Should I be using a different format when calling osascript from bash scripts?

Sure, you can use a here-document.

Code:
osascript << EOI
tell application "$appname"
    set bounds of windows whose visible is true to {$bounds}
end tell
EOI


Top
 Profile  
 PostPosted: Mon Sep 24, 2012 8:05 am   

Joined: Mon Sep 24, 2012 7:48 am
Posts: 5
merkuryo wrote:
Quote:
osascript -e "tell application \"$appname\" to set bounds of windows whose visible is true to {$bounds}"


Problem is, I get a "File <$appname> wasn't found" error.


I don't have any lions either, but I just wonder if -e does something funny with the slash quote. I would try
Quote:
osascript -e "tell application '$appname' to set ...

The single quotes act like regular characters when they're inside the double quotes. I do that a lot with eval in bash scripts.

One other thing looks very suspicious though: {$bounds}
Are you sure you don't mean ${bounds}?


Top
 Profile  
 PostPosted: Mon Sep 24, 2012 2:58 pm   
User avatar

Joined: Wed Jun 08, 2011 8:27 am
Posts: 189
Location: outer Shpongolia
He's cross-posted here.
As you can see, bounds is a comma-separated list of numbers, so nope there is no syntax error.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP