Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

diff commnand and the output

Status
Not open for further replies.

Popak

MIS
Oct 25, 2005
11
US
Hello,

I am inherting this automated script from the old sys admin, Would anybody please explain that to me? I do get this file called SIM07.txt every night, it would be depiped and this depiped file being compared to last night file and the diffrence being imported to our system, anyway this script stopped working last week and trying to figure out what is going on?
/usr/bin/diff /Volumes/Housing/UCSB\ Files/SIMSR/SIMD07-old.txt /Volumes/Housing/UCSB\ Files/SIMSR/SIMD07_depiped.txt | /usr/bin/perl -e 'while (<STDIN>) { if ($_ =~ /^>/) { $_ =~ s/^> //; print $_;}}' > /Volumes/Housing/UCSB\ Files/SIMSR/dir_toimport.txt;

thanks for your help,

-Popak
 
it looks like all it's doing is checking for a right arrow '>' at the beginning of the lines in the first file and removing them if there are any, and outputting those lines to the last file (dir_toimport.txt). Why it would stop working though I can't tell.

How do you know it stopped working? Have you checked the server error logs for any information about errors or warnings associated with that job/script?
 
thanks kevin,

but the diff statement doesn't work in this situaltion and the dir_toimport file that we get is empty, although there is a significant size diffrences between these two files. what can be wrong with the diff statment?

thanks
 
if there are no lines that start with > the output file will be blank. Can you open the input file and look at it and see if there are any lines that start with >


that's all the script does, so if you have some different conditions you should be checking for instead of lines beginning with > you need to change the perl code.
 
Kevin,

At this point we are just trying to do the diff command without using the statements after pipe, but we still get the empty file:
/usr/bin/diff /Volumes/Housing/UCSB\ Files/SIMSR/SIMD07-old.txt /Volumes/Housing/UCSB\ Files/SIMSR/SIMD07_depiped.txt | > /Volumes/Housing/UCSB\ Files/SIMSR/dir_toimport.txt;
 
well, this is no longer a perl question then. You could/should ask in the Unix(?) forum. Maybe someone else here can answer your question, I just don't know shell scripting enough to answer.
 
Is the path to the file correct?
Code:
/Volumes/Housing/UCSB\ Files/SIMSR/SIMD07-old.txt
what sort of path is this with a backslash and a space?
don't you wanna change it to a slash and no space?
Or i am missing something?


``The wise man doesn't give the right answers,
he poses the right questions.''
TIMTOWTDI
 
Have you enough disk space for the diff to run, I'd have thought it would have to create some temporary files, possibly for the two files being compared, for forwards and backwards checking.

Incidentally, why bother checking using a regex?
The position of the character to replace is known, so it would be quicker to use index in this case IMO.

Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
oh you backslash the space, ok i'm alittle tired i think.
Sorry for that.
Try to put the whole paths inside single quotes 'path'.
How big are the files anyway?


``The wise man doesn't give the right answers,
he poses the right questions.''
TIMTOWTDI
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top