Thread: How to start program from subfolder

  1. #1
    Registered User
    Join Date
    Dec 2005

    How to start program from subfolder

    OS Linux, C programming
    I have one folder itTestMenu in which are folders with programs. In program folders are executable files like a.out and similar. So main folder is a menu in which are subfolders where are programs that you choose from menu are located. I would just like to ask you how to write path of those programs that would just check subfolder of that name and executable file - that I wouldn't write path from whole system. If I transfer program(menu folder) to other location paths wont be right and programs from menu won't start, so I would like that no matter where the location of menu folder is it always checks the subfolder with that name and executable file ,so you can move folder and programs always start. Please help.
    Have a nice Day


  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Oregon, USA
    You can use setenv() to change the PATH shell variable. It only effects it for the running program, so when your menu program exits, the shell will still be using your old, unmodified PATH variable.
    If you understand what you're doing, you're not learning anything.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    You can use opendir()+readdir()+closedir()+stat() (POSIX functions) to figure out which files in a directory are directories. (And maybe chdir(), too.)

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Start program games
    By Livijn in forum C++ Programming
    Replies: 11
    Last Post: 04-18-2007, 11:01 AM
  2. how to make my program run on windows start up
    By kantze in forum A Brief History of
    Replies: 7
    Last Post: 03-24-2007, 11:14 AM
  3. Start up program
    By Breetai in forum Windows Programming
    Replies: 2
    Last Post: 01-11-2003, 01:12 PM
  4. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM
  5. Start a program
    By FunkeeMunkee in forum C++ Programming
    Replies: 1
    Last Post: 08-26-2001, 07:18 PM