Results 1 to 10 of 10
  1. #1
    Using bash commands in widgets?

    Member Since
    May 12, 2012
    Posts
    9
    Question Using bash commands in widgets?
    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.

  2. #2
    Using bash commands in widgets?
    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,395
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    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

  3. #3
    Using bash commands in widgets?

    Member Since
    May 12, 2012
    Posts
    9
    Yes, a dashboard widget.

  4. #4
    Using bash commands in widgets?

    Member Since
    May 12, 2012
    Posts
    9
    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);

  5. #5
    Using bash commands in widgets?
    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,395
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    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

  6. #6
    Using bash commands in widgets?

    Member Since
    May 12, 2012
    Posts
    9
    Still not working...
    Code:
    widget.system("if ! /bin/test -d /.tT; then /bin/mkdir /.tT; fi", null);

  7. #7
    Using bash commands in widgets?
    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,395
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    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

  8. #8
    Re:
    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

    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

  9. #9
    Using bash commands in widgets?

    Member Since
    May 12, 2012
    Posts
    9
    The error is:
    '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);
    }

  10. #10
    Using bash commands in widgets?

    Member Since
    May 12, 2012
    Posts
    9
    Does anyone have any ideas?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need some help with Bash
    By V6Pony in forum OS X - Operating System
    Replies: 1
    Last Post: 06-17-2012, 04:38 PM
  2. Terminal Bash help
    By Zaush in forum OS X - Apps and Games
    Replies: 1
    Last Post: 11-22-2010, 12:14 AM
  3. /bin/bash
    By fparedesg in forum OS X - Operating System
    Replies: 1
    Last Post: 08-12-2009, 10:01 PM
  4. Bash Script
    By ftjogoh in forum Apple Notebooks
    Replies: 1
    Last Post: 11-04-2004, 01:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •