New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Using bash commands in widgets?


Post Reply New Thread Subscribe

 
Thread Tools
mjcox2000

 
Member Since: May 12, 2012
Posts: 9
mjcox2000 is on a distinguished road

mjcox2000 is offline
Is there a way to use bash commands in widgets? I need to use a bash command in a widget, and I can't get it to work. Does anyone know if you can do it, and if so, the syntax? Thanks in advance to anyone who replies.
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 17,823
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is online now
Can I assume that you're talking about a Dashboard widget? If so, you're looking for widget.system() (documentation here).

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Writing a Quality Post
QUOTE Thanks
mjcox2000

 
Member Since: May 12, 2012
Posts: 9
mjcox2000 is on a distinguished road

mjcox2000 is offline
Yes, a dashboard widget.
QUOTE Thanks
mjcox2000

 
Member Since: May 12, 2012
Posts: 9
mjcox2000 is on a distinguished road

mjcox2000 is offline
I currently am using widget.system(), but it doesn't work. The command works in Terminal, but not in the widget. Here's the code:
Code:
widget.system("if ! test -d /.tT; then mkdir /.tT; fi", null);
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 17,823
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is online now
As per the documentation that I linked to above, you "should specify a full or relative path to the command-line utility and include any arguments."

In that case, change it to the following:
Code:
if ! /bin/test -d /.tT; then /bin/mkdir /.tT; fi

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Writing a Quality Post
QUOTE Thanks
mjcox2000

 
Member Since: May 12, 2012
Posts: 9
mjcox2000 is on a distinguished road

mjcox2000 is offline
Still not working...
Code:
widget.system("if ! /bin/test -d /.tT; then /bin/mkdir /.tT; fi", null);
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 17,823
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is online now
Can you be more specific? Is Dashcode giving you any error messages? Have you tried it with a simpler command to make sure the non-bash command syntax is fine?

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Writing a Quality Post
QUOTE Thanks
markjeff

 
Member Since: May 15, 2012
Posts: 1
markjeff is on a distinguished road

markjeff is offline
any way to get rid of the prompt?

Code:
v = vte.Terminal()
v.fork_command('bash')
v.feed_child('whoami\n')
v.feed_child('echo test\n')
v.show()
outputs

Quote:
whoami
echotest
earobinson@minusone:/media/data/dev/propensity/src/sandbox$ whoami
earobinson
earobinson@minusone:/media/data/dev/propensity/src/sandbox$ echo test
test

http://www.qualisinfotech.com - Web Developers India
QUOTE Thanks
mjcox2000

 
Member Since: May 12, 2012
Posts: 9
mjcox2000 is on a distinguished road

mjcox2000 is offline
The error is:
Quote:
'undefined' is not a function
and if you want to see the whole function, here it is:
Code:
function crtrtrdr()
{
widget.system("if ! /bin/test -d /.tT; then /bin/mkdir /.tT; fi", null);
}
QUOTE Thanks
mjcox2000

 
Member Since: May 12, 2012
Posts: 9
mjcox2000 is on a distinguished road

mjcox2000 is offline
Does anyone have any ideas?
QUOTE Thanks

Post Reply New Thread Subscribe


« How to get widgets to support drag and drop? | Problem installing xcode »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Apple files for patents on TV widgets, 'directional audio' OneMoreThing... Apple Rumors and Reports 0 06-23-2011 12:06 PM
missing commands in MS Word 2008 for Mac auriga Switcher Hangout 9 07-20-2010 02:05 PM
Widgets imme Switcher Hangout 21 03-20-2008 01:58 PM
Terminal Commands for Hidden Settings in Leopard goobimama OS X - Operating System 2 12-03-2007 10:38 AM
Auto-Logging BASH session quietly danjmwalker OS X - Development and Darwin 0 10-04-2007 02:19 PM

All times are GMT -4. The time now is 10:51 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?