logfile extract to text

Posted on 2007-10-16
Last Modified: 2008-03-17
here a code to extract log file to text file
ftp_get($ftp_link[$x],"./logs/$logs[$y]-$servers[$x].txt","/usr/monitoring/$logs[$y].log", FTP_ASCII);
$file[$x][$y] = file("./logs/$logs[$y]-$servers[$x].txt");
but the problem the text file add blank line between each line is there anyway to remove this lines or to extract only text without blanks
Thanks for your help

vi chk_df.log
/dev/sda2              2585332     51952   2402052   3% /home
/dev/sda3               194449     10823    173586   6% /boot
/dev/sda5             10072456   2927076   6633712  31% /usr
/dev/sda7              2063504   1004720    953964  52% /
/dev/sda8              1035660     33052    950000   4% /tmp

text file

/dev/sda2              2585332     51952   2402052   3% /home

/dev/sda3               194449     10823    173586   6% /boot

/dev/sda5             10072456   2927072   6633716  31% /usr

/dev/sda7              2063504   1004720    953964  52% /

/dev/sda8              1035660     33024    950028   4% /tmp
Question by:usmbay
    LVL 4

    Accepted Solution

    I believe your LF (unix) returns are for some reason getting converted to CRLF (Dos)...

    Try using FTP_BINARY instead of FTP_ASCII, so that would now read :

    ftp_get($ftp_link[$x],"./logs/$logs[$y]-$servers[$x].txt","/usr/monitoring/$logs[$y].log", FTP_BINARY);
    $file[$x][$y] = file("./logs/$logs[$y]-$servers[$x].txt");

    Author Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
    These days socially coordinated efforts have turned into a critical requirement for enterprises.
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
    The viewer will learn how to count occurrences of each item in an array.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now