LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-02-2005, 10:48 AM   #1
sebythomas
LQ Newbie
 
Registered: May 2005
Location: Within India and all over
Distribution: Fedora core
Posts: 1

Rep: Reputation: 0
Question calling another program alongwith arguments using execl not working


Hi,
Been at the problem for 2 long with no solution.Problem description : I have a core program written in GNU C having arguments where wild characters(-f file.*) is passed; the program uses getopt option to assess the arguments. This program is required to be called by a front end graphic interface built using libglade. I tried using execl and it's variants ; I have gone thru relevent man pages ; passing arguments and calling the program works with all other arguments except the ones where wild characters are used; Pl help
 
Old 06-02-2005, 12:37 PM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Re: calling another program alongwith arguments using execl not working

Quote:
Originally posted by sebythomas
passing arguments and calling the program works with all other arguments except the ones where wild characters are used
That's correct. Wildcards are processed by a shell, and exec..()-functions do not run the command inside a shell. This would be a chicken-egg problem, as shells themselves are written in C and need exec..() to run other processes....

Simplest solution:
Use system() instead of one of the exec..()-functions. System() does run the program inside a shell.

If you cannot use system(), because its functionality is too limited for you purpose, check out these functions (ordered from most sophisticated, to most basic):

man 3 wordexp
man 3 glob
man 3 scandir + man 3 fnmatch
man 3 opendir + man 3 readdir + man 3 fnmatch

Hope this helps.

Last edited by Hko; 06-02-2005 at 12:45 PM.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
newbie/program for calling BBS's Ltkpr49 Linux - Software 1 06-29-2005 09:45 AM
Problem calling linux program from Java spasco Programming 3 04-25-2004 12:13 AM
Passing external variables/arguments to SQL program ganninu Programming 12 11-25-2003 05:30 AM
Command line arguments to java program Majjj Programming 3 10-23-2003 05:48 AM
wine doesn't pass arguments correctly when calling programs jonchapman Linux - Software 0 10-08-2003 01:56 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration