|
-
November 5th, 2010, 04:33 AM
#16
Re: using linux commands in C++ code
I don't have that much Linux experience but I doubt that it will be any significant change in speed. After all redirecting the output using the > is pretty much the same thing as redirecting it using code. Anyway, if you want to test it adding those lines in main() should be sufficient.
-
November 5th, 2010, 04:38 AM
#17
Re: using linux commands in C++ code
Alright. Thanks S_M_A. Let me try this.
-
November 5th, 2010, 08:44 AM
#18
Re: using linux commands in C++ code
S_M_A it worked in C++ code and was much faster than it was when written explicitly on command line . Thanks
-
November 5th, 2010, 09:03 AM
#19
Re: using linux commands in C++ code
Someone suggested me this example "http://www.cplusplus.com/reference/iostream/ios/rdbuf/" which I found a bit easier and it worked as well but not when I tried to use it with the output of this command
Code:
system("diff /home/test1.txt /home/test2.txt");
Do you have any idea why? it still prints the output on to the screen and not to a file.
-
November 5th, 2010, 10:24 AM
#20
Re: using linux commands in C++ code
Hm sounds like a system call does not run in an exact copy of the parent process environment. Amazing also that there was a difference. You learn something new every day... 
I guess you could change the diff call to redirect the output? Try that and I'll browse around abit to check if there's some other way to do it.
-
November 5th, 2010, 10:38 AM
#21
Re: using linux commands in C++ code
Thanks S_M_S
could you please write to me a line of code for changing the diff call to redirect the output?
-
November 5th, 2010, 11:48 AM
#22
Re: using linux commands in C++ code
Nope, I didn't find any new info regarding this. 
You redirect just as you've done before by using > on the command line.
-
November 5th, 2010, 11:56 AM
#23
Re: using linux commands in C++ code
Alright Thanks a lot any way.
I have just found a code which is I think written in perl. Could you please tell me the meaning of each of these lines because I ran this code and it worked exactly what I needed
Code:
#!/bin/bash
counter=1
exec 3< /usr/local/test1.txt
while read -u3 line
do
grep "$line" /usr/local/test1.txt2>/dev/null
if [[ $? -eq 1 ]]
then
echo "Line $counter is not present in Naginas_Exp_0206_non_dupCME file!!!"
fi
(( counter += 1 ))
done
-
November 5th, 2010, 12:19 PM
#24
Re: using linux commands in C++ code
 Originally Posted by heidiK
Alright Thanks a lot any way.
I have just found a code which is I think written in perl. Could you please tell me the meaning of each of these lines because I ran this code and it worked exactly what I needed
Code:
#!/bin/bash
counter=1
exec 3< /usr/local/test1.txt
while read -u3 line
do
grep "$line" /usr/local/test1.txt2>/dev/null
if [[ $? -eq 1 ]]
then
echo "Line $counter is not present in Naginas_Exp_0206_non_dupCME file!!!"
fi
(( counter += 1 ))
done
That's a bash script, not PERL. Just type 'man bash' on your *NIX terminal.
Viggy
-
November 5th, 2010, 12:25 PM
#25
Re: using linux commands in C++ code
-
April 20th, 2011, 02:58 PM
#26
Re: using linux commands in C++ code
Here you can check out the most used linux commands .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|