Sir please consider the following....
I would like to copy contents from one file (mart1.c) to another file (mart2.c) using execv() function (using command line arguments).....
The command line argument string is "cp mart1.c mart2.c"
Consider the following code..
int main (int argc, char *argv[])
{
char c[]="cp mart1.c mart2.c";
argv[0]=strtok(c," " );
argv[1]=strtok(0," " );
argv[2]=strtok(0," ");
execv("/bin/cp","cp",argv);
}
The contents are not getting copied when I run this code...Is there mistake in the code..Kindly correct the above code...
Thank you..
3 13369
I have moved this thread to the C forum. Hopefully you will find help there.
Hi, -
int main (int argc, char *argv[])
-
{
-
char c[]="cp mart1.c mart2.c";
-
//argv[0]=strtok(c," " ); //Instead of assigning do strcpy
-
strcpy(argv[0],strtok(c," " ));
-
argv[1]=strtok(0," " );
-
argv[2]=strtok(0," ");
-
execv("/bin/cp","cp",argv);
-
}
-
-
Replace assignment with strcpy and then try it...that will solve the issue.
Thanks
Raghuram
Hi, -
int main (int argc, char *argv[])
-
{
-
char c[]="cp mart1.c mart2.c";
-
//argv[0]=strtok(c," " ); //Instead of assigning do strcpy
-
strcpy(argv[0],strtok(c," " ));
-
argv[1]=strtok(0," " );
-
argv[2]=strtok(0," ");
-
execv("/bin/cp","cp",argv);
-
}
-
-
Replace assignment with strcpy and then try it...that will solve the issue.
Thanks
Raghuram
Thank you Sir....
Sir could u please tell me the difference between copying and assigning...
Thank you...
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mike Vieths |
last post by:
I'm running into a problem when I try to run commands with os.execv. It
seems to be putting quotation marks around each element of the list
passed as its second argument. This is fine for the...
|
by: Shalen chhabra |
last post by:
Hey,
Can anyone give me a snippet for running a python program over all the files
in the directory.
For ex: I have ten files in a directory and I want to run a python program
against all of...
|
by: New |
last post by:
How can I uses a pipe to get the output from a execv() and redirect it to a
parent process?
in ansi c if possible
Thank-you
|
by: Douglas Dillon |
last post by:
I am trying to use tiffcp to reconfigure tif files (if they are tiled)
to nontiled so I can use existing code to handle them. However, I am
having issues providing the arguments. The app is run...
|
by: freehomesp |
last post by:
1 #include <sys/types.h>
2 #include <sys/times.h>
3 int
4 main(int argc,char* argv)
5 {
6 struct tms before, after;
7
8 times(&before);
9
10 pid_t pid;
|
by: ash |
last post by:
hi,
i want to know is there a way to run/control an external program form
within a python program?
thanks in advance for any support.
|
by: Þ¾¯ |
last post by:
/************************************************** ***
*** chrexec.c ***
*This shit can be called from root or from any user (in that case executable
* should have 06755 permisions) and should...
|
by: michael |
last post by:
Hi All,
I am trying to create an array the same as the char *argv that is passed
to main() ie main(int argc, char *argv)
I need to store a pointer to and integer in one of the elemets, but the...
|
by: CMorgan |
last post by:
Hi everybody,
I am experiencing an annoying problem with fork() and execv().
In my program I need to launch the "pppd" from a thread, so, I create
a new process with fork and then in the child...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |