Solved

executing a dos program with execl

Posted on 1998-09-03
1
206 Views
Last Modified: 2010-04-10
Hi,
     First i would just like to say i am a beginner with c++ so i know there is probably a better way to do this but can you fix this first and then put any other suggestion at the end.

I have written some small dos programs.  I want to write a small menu system program to execute my programs.  I found the command execl in the help menu but i can't get it to work.  It just says file not found.  It compiles and runs but it just can't find the file, which does exist.  Can you edit this code so it does work.  Thanks (I am using turbo c++)





//FILE: options.cpp
//    Date: Sept 03-98
//Menu system to choose what program to run

#include <iostream.h>
#include <stdio.h>
#include <fstream.h>
#include <ctype.h>
#include <process.h>


void select (char);

void main()
{
      char choice;

      do
      {
            cout << endl << "1) Cir_on";
            cout << endl << "2) Cir_od";
            cout << endl << "q) quit";
            cout << endl << "Enter number of program you wish to run: ";
            cin >> choice;
            select (choice);
      }
      while (toupper (choice) != 'Q');

}

void select (char choice)
{
      char path[80] = "c:\\nc\\anilam\\";
      char argv[40] = "cir_od.exe";
      switch (toupper (choice))
      {
            case '1':
            cout << endl << "executing cir_od...";
            execl(path,argv);
            perror("EXEC:");
            break;

            case '2':
            cout << endl << "executing cir_on";
            break;

            case 'Q':
            cout << endl << "okay bye";
            break;

            default:
            cout << endl << "choose again";
            cin.ignore (80, '\n');

      }
}


0
Comment
Question by:onestar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 8

Accepted Solution

by:
Answers2000 earned 50 total points
ID: 1172005
The first param of execl is the full path of the program, the arg (2nd and onwards) parameters are the command line options passed to the program

Change

char path[80] = "c:\\nc\\anilam\\";
char argv[40] = "cir_od.exe";
.etc...
execl(path,argv);

Into

char path[80] = "c:\\nc\\anilam\\cir_od.exe" ;
char argv[40] = "" ;
.etc...
execl(path,argv);


0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question