The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers > Homework & Coursework Questions
.
google unix.com



Homework & Coursework Questions Students must use and complete the template provided. If you don't, your post may be deleted! Special homework rules apply here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem with socket binding - "system" call Janardhanbr High Level Programming 5 05-10-2009 09:48 AM
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-20-2007 01:52 AM
grep to find content in between curly braces, "{" and "}," keshav_rk Shell Programming and Scripting 4 08-09-2007 10:14 PM
error "Invalid argument" returned after call sched_setscheduler robin.zhu High Level Programming 1 07-26-2007 03:51 AM
Network Path Not Found Error "Sunfire V100" louisd11 SUN Solaris 4 12-13-2006 01:20 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 4 Weeks Ago
andersbranderud andersbranderud is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 2
Problem solved! How to use a execvp-call to do "grep PATH"?

Hello!
I am learning how to use the function execvp. I have read through the UNIX manual.
I have a process. I run execvp and I command it to do “printenv”. It works fine.
Before I do the execvp-call I pipe STDOUT to go to a specific pipe. After that I restore STDOUT. I read that pipe in another process. I have tested it and it works.

Now in this other process I want to do execvp again and I want to command execvp to do “grep …”.
I don’t succeed in doing this.

Here is some of my code:
char* environment_variables_vector[60];
My function call is this: execvp ("grep", environment_variables_vector)

Environment_variables_vector have this format:
Position 0 is a pointer to the string “grep PATH”
Position 1 is a pointer to: A nulterminated string containing an environment variable
Position 2 is a pointer to: Another nulterminated string containing another environment variable
..etcetera, up to
Position 52 is a pointer to: Another nulterminated string containing another environment variable.

When I run the program it doesn’t run the code after the execvp-call.

4. School (University) and Course Number:
Royal Technical Highschool, ID2206

Thanks for your help!

EDIT: Problem solved!

Anders Branderud
proofofaCreator.wordpress.com

Last edited by andersbranderud; 4 Weeks Ago at 05:45 AM..
  #2 (permalink)  
Old 3 Weeks Ago
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2005
Location: Switzerland - GE
Posts: 1,568
What was the issue ?
  #3 (permalink)  
Old 3 Weeks Ago
andersbranderud andersbranderud is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 2
Vbe wrote: "What was the issue ?"

My reply:
As I wrote,
"Now in this other process I want to do execvp again and I want to command execvp to do “grep …”.
I don’t succeed in doing this."

Why I didn't succeed in doing it was because my inparameters were not correct. After reading the manual pages more carefully and searching on google how others did the same, I solved the problem.

Last edited by pludi; 3 Weeks Ago at 06:33 AM.. Reason: removed self promotion
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:10 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0