0

I have a perl script who takes files from the following path: /home/ict/extract and when i run this perl script -> this perl script has 3 options, if i choose all these 3 options, this script will create 3 files - if i choose 2 options it will generate only 2 files -> on the following path /home/ict/data. This scripts also generates a log file with the followng output:

Log for 2 operations: Type_1 and Type_2 ( if there will be 3 types, we will have another line into this log file)

"Selected Type_1 Selected /home/ict/extract/file.csv as Extract file Created outputfile different_file_name.dat into output directory: /home/ict/data/

Selected Type_2 Selected /home/ict/extract/file2.csv as Extract file Created outputfile different_file_name2.dat into output directory: /home/ict/data/ "

I want to compare if the number of records from the original file ( from /home/ict/extract is the same like the one from /home/ict/data ) ( original file and file processed are the last created ones )

If it's ok, send email with the file from /home/ict/data as attachment

If not, show on display message.

I know i have to use wc -l but i'm new.

Thank you!

1 Answers1

0

Generally it is considered good form to show that you have worked through the problem some and post some code you are working with rather than to ask for someone to write it for you. I'll point you in the right direction:

ORIGINAL_FILE=/home/ict/file.txt
if [ -e $ORIGINAL_FILE ]; then
    ORIGINAL_FILEWC=`wc -l "$ORIGINAL_FILE"`
elif
    echo "oops, missing orig file"
    exit 255
fi

NEW_FILE=/home/ict/file_new.txt
if [ -e $NEW_FILE ]; then
    NEW_WC=`wc -l "$NEW_FILE"`
elif
    echo "oops, missing new file"
    exit 255
fi

if [ $NEW_WC -eq $ORIGINAL_WC ]; then
    echo "You would put some code here for the files being equal length"
elif
    echo "Looks like they're not equal."
fi

I am very curious why you would not just do this in perl however. I assume you know about things like -e and File::Slurp? This is quite trivial to do in perl.

jane arc
  • 574
  • 3
  • 16
  • Hello, Thank you very much for your answer. I managed to create this script some days ago. I didn't had time to check the answers here ( very busy with work ). My scripts works now and it sends email with the processed file. – user2878316 Oct 29 '13 at 15:38