flat assembler
Message board for the users of flat assembler.

Index > Linux > call shell command

Author
Thread Post new topic Reply to topic
belhifet



Joined: 03 Oct 2006
Posts: 2
belhifet 22 Nov 2006, 21:43
How do I call a bash built-in command?
"echo" for example.

I need the equivalent of C's system("echo hello");
Post 22 Nov 2006, 21:43
View user's profile Send private message Reply with quote
lsa



Joined: 10 Aug 2006
Posts: 17
Location: Denmark
lsa 30 Nov 2006, 19:21
You can use the syscall 'execve' to execute another program from within yours (it takes over your program).
The 'system' word in C does (as far as i can remember) also fork a new process to allow the calling program to continue, so the procedure is as follows:
##
Fork
And then from Child: execve ("/bin/echo",0,0)
##
See: man 2 execve, man 2 fork for usage.

Sorry, don`t have time to find/write the exact code for you at this momemt.
Post 30 Nov 2006, 19:21
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.