LinuxQuestions.org
Help answer threads with 0 replies.
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 03-12-2005, 12:23 AM   #1
Eshah
LQ Newbie
 
Registered: Mar 2005
Location: USA
Posts: 1

Rep: Reputation: 0
C programming


Hi,
I have a problem in doing C programming. Actually, in my code I have to pass 2 arguments like:
less filename.c
I would like to know how can I display my file by creating a child process by giving the above arguments?. Also, how can I use such arguments in the execvp(), function of a child process?

Thanks!

Code:
pid_ t pid;
char* argv[100];

if((pid=fork())==0)

// It works fine for "ls" only but not for 'less Filename'.......????
excevp(argv[0], argv)
perror(argv[0]);
exit(0);
else
wait(NULL);
 
Old 03-13-2005, 10:48 AM   #2
live_dont_exist
Member
 
Registered: Aug 2004
Location: India
Distribution: Redhat 9.0,FC3,FC5,FC10
Posts: 257

Rep: Reputation: 30
hi,
tell you what..if I'm not wrong theres around 6 different versions for exec ; execvp is just one of them . I'm not too sure about the syntax here but execvp is execvp(const char * path , argv[]) {ONLY 1 ARGUMENT...hence ls worked} . I believe the other versions of exec will help you out . For further assistance check out man 3 exec .
hope it helps
Arvind
 
Old 03-14-2005, 02:24 AM   #3
nixcraft
Member
 
Registered: Nov 2004
Location: BIOS
Distribution: RHEL3.0, FreeBSD 5.x, Debian 3.x, Soaris x86 v10
Posts: 379

Rep: Reputation: 30
Did you tried to run it as follows?

./yourprogr "'less Filename'"
 
  


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
which programming language is used to do tcp/ip programming?? gajaykrishnan Linux - Networking 9 12-21-2012 05:16 AM
im new to programming but..... boxerboy Programming 6 08-26-2005 06:17 AM
Difference between Top Down programming & Bottom up programming minil Programming 1 06-17-2005 02:42 AM
C programming oranj Linux - Networking 1 12-07-2004 12:40 AM
Qt Programming... jinksys Programming 1 08-06-2003 04:33 AM

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

All times are GMT -5. The time now is 03:04 PM.

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