Runbox, execute a program.

This is a discussion on Runbox, execute a program. within the Linux Programming forums, part of the Platform Specific Boards category; Hey there, I am trying to write a runbox for linux, like in Gnome or KDE when you press Alt+F2. ...

  1. #1
    Registered User Bill Cosby's Avatar
    Join Date
    Sep 2004
    Posts
    11

    Question Runbox, execute a program.

    Hey there,

    I am trying to write a runbox for linux, like in Gnome or KDE when you press Alt+F2.
    The crux is, I am not sure how I can even start a program from my code base..

    I tried system and execvp, however, it doesn't work, I get lots of errors like with acroread:

    Code:
    /usr/local/bin/acroread: line 204: sed: command not found
    /usr/local/bin/acroread: line 229: dirname: command not found
    If I try blender (a 3D program) it works, so it has to be the way the command is actually executed, my program is a GTK+ app, so it most likely has to be a terminal thing? Or do I need bash and I just get sh with system and execvp?

    How could I change that bash is sed instead of sh, basically, I need to rewrite system, don't I?

    Anyway, thanks in advance.
    Bill

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    What do you get if you do
    Code:
    printf("path = %s\n", getenv("path"));
    Does your sed or acroread reside in a place that you can reach with that path?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User Bill Cosby's Avatar
    Join Date
    Sep 2004
    Posts
    11
    Quote Originally Posted by matsp View Post
    What do you get if you do
    Code:
    printf("path = %s\n", getenv("path"));
    Does your sed or acroread reside in a place that you can reach with that path?
    Yes, it does, i specifically get the commands from a list of files, I got from the path variable.

    The path does give "/usr/local/bin/:/bin" however sed s in /bin and acroread in /usr/local/bin, could this make problems?
    Well I can just start it by entering acroread into a terminal, so this shouldn't be the problem. I still suspect it to be bash, anyway I could bash as an executing shell?

    regards,
    Bill
    Last edited by Bill Cosby; 10-17-2007 at 06:29 AM.

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Haven't got an idea. It looks like you have a shell-script as acroread, so maybe you can modify it to debug it?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User Bill Cosby's Avatar
    Join Date
    Sep 2004
    Posts
    11
    Quote Originally Posted by matsp View Post
    Haven't got an idea. It looks like you have a shell-script as acroread, so maybe you can modify it to debug it?
    It's weird, I know traced the problem to be gtk itself, if I call execvp() before the gtk_main() then it works flawlessly, when I try to call the function from within the gtk_main() (through signal binding of widgets) it doesn't work.
    I even tried the glib function g_spawn_async() but it has the exact same problems.

    It must be a gtk thing.

    Any thoughts?
    Thanks for your effort so far though, regards,
    Bill

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,656
    execvp searches the PATH, so if something modifies the PATH either side of calling gtk_main(), then you will observe different behaviour.

    Things like 'sed' should be in standard places, so you shouldn't need the 'path' version to find them.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. a program that will call an execute but with arguments
    By what3v3r in forum C++ Programming
    Replies: 3
    Last Post: 01-19-2006, 08:44 PM
  2. Need help on code to execute the program
    By hibmem10 in forum C++ Programming
    Replies: 6
    Last Post: 12-24-2005, 12:42 PM
  3. Can't execute my program
    By bahruddina in forum C Programming
    Replies: 4
    Last Post: 07-13-2004, 10:19 PM
  4. simple frontend program problem
    By gandalf_bar in forum Linux Programming
    Replies: 16
    Last Post: 04-22-2004, 06:33 AM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21