![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| compare two col from 2 files, and output uniq from file 1 | pp56825 | Shell Programming and Scripting | 2 | 01-10-2008 11:10 AM |
| Aggregate values in a file & compare with sql output | shiroh_1982 | UNIX for Dummies Questions & Answers | 1 | 09-02-2007 07:40 AM |
| How to compare file size after ftp? | icemania | Shell Programming and Scripting | 1 | 07-09-2007 11:17 PM |
| compare 2 files, output dups to file | blt123 | UNIX for Dummies Questions & Answers | 2 | 07-15-2004 10:31 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Hi guys,
firstly I'm working on SunOS 5.10 Generic_125100-10 sun4u sparc SUNW,Sun-Fire-V240 I've made a script to compress two directory and then send them to an other server via ftp. This is working very well. Inside theis script I decide to log usefull data for troubleshooting in case of need. quit easy until now. I need to send some information by mail to a anaware person. this information would be the data has been compressed well and are base on the ftp server or the backup transfert hasn't worked well. Here is starting the interesting clue ![]() ![]() ![]() Then I send to a file (INFO) the output of ls -l of the Compressed file and theDIR ftp output which are like this : -rwxrwxrwx 1 ftpfintel ftpuser 2103425 Nov 5 11:40 ftptestsys.tar.Z -rw-r--r-- 1 root root 2103425 Nov 5 11:56 ftptestsys.tar.Z Then I create a function to sort out and get only file name and size and owner that I send to a file (MAIL). which is like this : root 2103425 ftptestsys.tar.Z ftpfintel 2103425 ftptestsys.tar.Z Now from this or from an other way, I would like to create a check between the size of the two files. Have you and idea, I'm trying to user eq but nothing good and do you know how can read the content of MAIL and get something like MAIL < if [ [0-9] eq [0-9] then echo "transfert ok" else echo "transfert defect" |
|
||||
|
Thanks Gus2000
Can you pls let me know how I can plug the file size without creating many files. Is it possible to let the script stay in without doing many files with each output? If I do my function to get only the size from each it means that the script will create 4 files (1=size ftp, 1=sizefrom system ls for each directory saved) May be their is a way to keep those info inside the script shell? Thks ![]() |
|
||||
|
pouf an other issue, I'm fitting with my script to make it reliable
![]() ![]() here is ... in the reality for the test a and b are equal number c and d are different number a=ISL b=ISF c=INL d=INF eg more $d 48922183 if [ "$c -eq $d" ] ; then echo "Sys File sizes match" ; else echo "Sys File sizes differ Errror" ; fi When I launch this I get the same reply for both case which is wrong a=b and c diff d I've tryied may possibilities with [[]] and "" and = but no one is working well. any one can help pls? |
|
||||
|
comaprison is incorrect
You need to get the file sizes into the variables. For ex,
Code:
a=`wc -c filename1 | nawk '{print $1}` ## can use a combination of ls and nawk too
b=`wc -c filename2 | nawk '{print $1}'` ## can use a combination of ls and nawk too
##Have used nawk as you have mentioned Solaris. Please change to 'awk' otherwise
|
|
||||
|
Thanks ranj@chn
it's very interesting. It helps me to get less unuseful data file. But it's not working as well. If I do the test with a=b and c diff d I always get the same answer rather I should get a=b ok c=d not ok Sure filename cannot be used for that so I create a function here below : test () { cat $1 | grep [*.Z] | awk '{print $5}' | sed -e 's/printing//g' -e 's/(8192//g' -e 's/on.//g' -e '/^$/d' test "$INFOSYSL" > "$DIRLOG/ISL" test "$INFOSYSF" > "$DIRLOG/ISF" test "$INFONETL" > "$DIRLOG/INL" test "$INFONETF" > "$DIRLOG/INF" a=$ISL b=$ISF c=$INL d=$INF export a b c d if [ "$a" -eq "$b" ]; then echo "Sys File sizes match" else echo "Sys File sizes differ Errror" fi >> $MAIL if [ "$c" -eq "$d" ]; then echo "net File sizes match" else echo "Net File sizes differ Errror" fi >> $MAIL |
|
||||
|
Just to complet. One of the data came from FTP so I have to go accross a file where I push some useful input ls -l and dir result.
What I'm not arriving to do is to read the data and compare it. |
| Sponsored Links | ||
|
|