[SOLVED] diff command reports 256 error value instead of success and failure results
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
diff command reports 256 error value instead of success and failure results
Hi All,
When I run a script in perl, something like below: I`m stuck up in the error result as 256. Appreciate the solution for the below script
using:sunOS 5.10
Quote:
my $result = system("diff Tmp_IcdGenFile_log.c Tmp_DumpFile_log.c");
if(system("diff Tmp_IcdGenFile_log.c Tmp_DumpFile_log.c") == 0) {
print "There is no difference in the file $F_DPath\n";
}#-b option added to ignore whitespace --ignore-matching-lines='^#'
elsif($? == 1) {
print "yes, there is a difference in the file $F_DPath\n";
Basically, I`m an embedded professional. So, I`m aware of the system calls being used for.
Surprised to see the return values of the system call for diff in perl.
Actually, what the "system("diff file1 file2")" should return in general(I suppose in perl)?
Some how when I do cpp -p -fpreprocessed -E Tmp_IcdGenFile.c >log.txt ..etc to remove the comments in a file.
The file name along with the line numnber(i.e., ex# 44 Tmp_IcdGenFile_o_log.c) is being appended twice in the log file and when I take the diff of the generated two log files.
The out put of the diff is always different(as the line number and the file names are always different).
Now, the question comes here is, how to avoid the appending file name and line number while generating the log files ?
As we know during the processing stage the comments are ignored and hence the approach is being implemented.
I would have used "cc -E file". But, because of some version issues of the compiler trying to run the command in cpp.
1)need to ignore the comments in two files located in different paths(say ../home/rajesh/core/modified.c and /home/rajesh/modified.c)
-> if we edit one file(say /home/rajesh/modified.c file) in the comment section we need to considered it as no change to the file and if we change in other places need to consider it as a change in the file
2)If it is a change in the file as per the above conditions, the file need to be moved to other location (i.e., by renaming the older(mv /home/rajesh/core/modified.c /home/rajesh/core/modified_old.c) file and copy the changed file to the location(cp /home/rajesh/modified.c /home/rajesh/core/modified.c))
and I`m stuck @ removing the comment from the .c file(as it is appending the file name and line number in the file) result in always a change in the file while taking the diff.
Hope this will help you to understand the issue here.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.