473,500 Members | 1,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

execl

9 New Member
I have a problem calling a compiled program (for example hello.exe which stands for hello world) from another program (let's say time.exe) with execl function


/* program time.c */
#include <stdio.h>
#include <unistd.h>

main (int argc, char *argv[])

{
int i;

execl(argv[i], (char *) 0);
}


although it compiles,

when I call it with command ./time -hello it produces no output but segmentation fault. I am using bash shell


thank you all guys
Apr 20 '07 #1
1 4377
JosAH
11,448 Recognized Expert MVP
I have a problem calling a compiled program (for example hello.exe which stands for hello world) from another program (let's say time.exe) with execl function


/* program time.c */
#include <stdio.h>
#include <unistd.h>

main (int argc, char *argv[])

{
int i;

execl(argv[i], (char *) 0);
}


although it compiles,

when I call it with command ./time -hello it produces no output but segmentation fault. I am using bash shell


thank you all guys
Better make that:
Expand|Select|Wrap|Line Numbers
  1. execl(argv[1], argv[1], null);
and leave out the minus sign on your command line:
Expand|Select|Wrap|Line Numbers
  1. ./time hello
Note that your local variable 'i' isn't initialized; I replaced it with a literal 1.

kind regards,

Jos
Apr 21 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
3013
by: python newbie | last post by:
Can anyone tell me why this would cause "Invalid Number of Parameters" while trying to compile (or interpret or whatever) import os...
4
1798
by: Chris Green | last post by:
Hey folks, I'm whipping up a quick CGI to wrap a command line app and I was a bit suprised to not find a execl-like Popen3 style object. I don't want to bother with the shell interpreting...
2
2379
by: Erik Johnson | last post by:
Hi, I am trying to use Python to remap stdout and stderr to a log file for an exec()'ed program. The following code seems to work fine for the script itself, but my expectation was that the...
0
1306
by: Michael | last post by:
Hi All, I created a web page from Excel2000, using "Save as web page..."...Publish function. then, I moved htm file to my IIS web server. Then I added a form control, and submit button. How...
3
17366
by: PC | last post by:
Is it possible to create pipe()s (stdin/stdout) for a child process and forking a shell with execl() and controlling the shell's stdin/stdout from the parent with select()? Heres a little snippet...
1
6150
by: shalombi | last post by:
I am having a weird result with the execl() func under windows (i know its meant for unix). When I put the execl in a piece of code then run the app and when I give a value to execl all it does is...
1
3402
by: kisshug | last post by:
i 'm working on a project in that i have 2 use 'execl' function can any one give how to use this function with 2 small programs in unix environment. -- kisshug Message posted via ...
0
906
by: vishalgupta | last post by:
while working on vb we can work with acess and sql as backend but can we work with execl in backend ......is it efficient and easier to work with execl in backend or access in backend and why??
4
2411
by: Sam | last post by:
I have a program which works great when run from the command line. But when I run it combined with something else such as: - piping it through less - cron - execl (i.e. calling it from another...
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7229
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7395
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5485
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4921
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
311
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.