Tuesday, April 20, 2010

Migrating your squirrel mail contacts to roundcube

A simple script that will convert squirrel web mail contacts of each user to vcard format that can then be imported to roundcube webmail.

#!/bin/bash
for x in `ls *.abook`
do

cat $x | while read line
do
echo "BEGIN:VCARD" >> $x.vcf
echo "VERSION:3.0" >> $x.vcf
echo -n "N:" >> $x.vcf
echo -n `echo $line | cut -d'|' -f3` >> $x.vcf
echo -n ";" >> $x.vcf
echo `echo $line | cut -d'|' -f2` >> $x.vcf
echo -n "FN:" >> $x.vcf
echo `echo $line | cut -d'|' -f1` >> $x.vcf
echo -n "EMAIL;TYPE=PREF,INTERNET:" >> $x.vcf
echo `echo $line | cut -d'|' -f4` >> $x.vcf
echo "END:VCARD" >> $x.vcf
echo >> $x.vcf

done

echo "done $x"
done
To use this script: login on the server where squirrel mail is installed and browse to squirrel mail's data directory where squirrel mail keeps its .abook and .pref and .sig files.

Next create a file by the name of "makevcard" and paste this script in that file.

Next make the file executeable by running the following command

#> chmod +x ./makevcard


Now execute the script by

#> ./makevcard

Squirrel mail saves the address book for every user in a separate file, for example name@domain.com.abook. After this script is executed, For every .abook file, you'll get .abook.vcf file that will be in vcard format.

copy all the .vcf files to any location you like and you can now use your roundcube built in "Import Contacts" Feature to import contacts of individual user;

52 comments:

  1. Hi!

    Shouldn't you use the line 2 like this?

    for x in `ls *.abook`

    There's no need to run the operation on .sig, .pref and .cal files.

    BTW, thanks for the script. It really helps a lot!

    ReplyDelete
  2. Hi oandarilho01,

    you are right, thanks for the correction.

    ReplyDelete
  3. Thanks for this great post! Really helped me out :-)

    ReplyDelete
  4. I know this is a bit old, but `ls *.abook` could be more simply just *.abook

    ReplyDelete
    Replies
    1. This is very old now the people use snapchat login to get in touch with eachother

      Delete
  5. here is my php script:

    ----
    #!/usr/bin/php -q
    <?php

    // squirrelmail data dir
    $DATA = "/var/local/squirrelmail/data/";

    // Roudncube DataBase
    $mysql_link=mysql_pconnect("localhost","root","*****");

    mysql_select_db("roundcube");
    $sql = "select user_id,username from users order by user_id";
    $Resp= mysql_query($sql);

    while( $row = mysql_fetch_array($Resp) ){

    $file = $DATA.$row["username"].".abook";

    if(file_exists( $file )){
    $handle = fopen( $file , 'r');
    while (!feof($handle)) {
    $buffer = fgets($handle, 4096);
    if(trim($buffer)){
    list($nick,$nombre,$apellido,$email,$empresa) = explode("|",$buffer);
    if( trim($email) ){
    $sql2 = "select email from contacts where user_id='".$row["user_id"]."' and email='$email' ";
    $Resp2= mysql_query($sql2);
    if(mysql_num_rows($Resp2)==0){
    print "Adding $email to ".$row["username"]." ...";
    $sql3 = "insert into contacts set name = '$nick', firstname = '$nombre',
    surname = '$apellido', email = '$email',
    user_id = '".$row["user_id"]."' ";
    $Resp3 = mysql_query($sql3);
    if($Resp3) print " Ok\n";
    else print " Fail\n";
    }
    }
    }
    }
    }
    }


    ReplyDelete
  6. Thanks for that k4b3za.
    A suggestion for those who use this script in future:

    Remove these lines:
    $sql3 = "insert into contacts set name = '$nick', firstname = '$nombre',
    surname = '$apellido', email = '$email',
    user_id = '".$row["user_id"]."' ";

    Replace with:
    $changed = date('Y-m-d H:i:s');
    $sql3 = "insert into contacts set changed = '$changed', name = '".mysql_real_escape_string($nick)."', firstname = '".mysql_real_escape_string($nombre)."',surname = '".mysql_real_escape_string($apellido)."', email = '".mysql_real_escape_string($email)."',user_id = '".$row["user_id"]."'; ";

    Also make sure you remove the line wrap from the $sql3 line above else it may not import correctly.

    What I did: Added the datestamp to correctly format that field in your Roundcube database, and used mysql_real_escape_string to fix any names with an apostrophe (eg., O'Hara), which would have broken the script. I also added a semicolon just for good form.

    Once a user edits their contact in Roundcube (eg., adding a phone number), the VCARD will be automatically populated. k4b3za's script will not create duplicates since it first checks if the user is already in their address book.

    ReplyDelete
  7. đồng tâm
    game mu
    cho thuê nhà trọ
    cho thuê phòng trọ
    nhac san cuc manh
    số điện thoại tư vấn pháp luật miễn phí
    văn phòng luật
    tổng đài tư vấn pháp luật
    dịch vụ thành lập công ty trọn gói
    nước cờ trên bàn thương lượng
    mbp
    erg
    nghịch lý
    chi square test
    nghệ thuật nói chuyện
    coase
    thuyết kỳ vọng
    chiến thắng con quỷ trong bạn
    cân bằng nash

    Triệu Quốc Đống cười nói.

    Phó Thiên đành phải nói:
    - Vậy cậu định bố trí ở đâu, sếp cũ của cậu cũng không quá kém mà?

    - Khách sạn Văn Hoa đi, hai hôm trước tôi cùng bạn ăn ở đó, tôi thấy cũng được.
    Triệu Quốc Đống nói.

    Phó Thiên ngẩn ra, khách sạn Văn Hoa không kém, được xưng không phải năm sao nhưng quá năm sao. Triệu Quốc Đống này không đơn giản, ở đó tiêu một lần không dưới vài ngàn. Nếu như giải trí thêm thì lại còn hơn nữa.

    - Được, 6h30 tuổi chúng ta tới đó, sợ rằng phải sớm đặt chỗ mới được.
    Phó Thiên nói:
    - Cậu đi thế nào, có cần chúng tôi đón không? Đừng có mà đi chiếc Mitsubish của Phòng cao tốc đó.

    - Ừ, không cần, tôi biết.
    Triệu Quốc Đống gật đầu nói.
    - Quốc Đống, Chủ tịch Tô rất hài lòng về bài viết mà chú và Lôi Hướng Đông viết. Chủ tịch rất vui vì sở ta có nhân tài. Lần này mời các tập đoàn quốc tế tới An Nguyên khảo sát mặc dù hơi đột ngột nhưng chủ tịch Tần cũng lên tiếng giúp chúng ta. Lãnh đạo sẽ không nói thêm gì nhưng về sau không được phạm sai lầm như vậy.

    - Ha ha, Thái ca, nếu đi theo con đường bình thường thì kéo đến bao giờ chứ? Em dám cược chúng ta dù đưa ra ý kiến thì một hai tháng cũng không có ý kiến. Nếu chờ đến khi báo lên Ủy ban kế hoạch phát triển quốc gia phê chuẩn, sau đó mới mời các tập đoàn đến khảo sát, em thấy sang năm đã là nhanh. Không bằng làm nhanh một chút, hơn nữa đây cũng không phải tiền trảm hậu tấu mà.

    ReplyDelete
  8. I have spent a lot of the time in different blogs but this is really a unique blog for me.
    http://kbmdc.org/squirrel-traps/

    ReplyDelete
  9. Choosing the correct locking boxes for your home is essential, as it will provide you with a sense of relief that when you go away you mail is protected. Having your mail protected will stop identity theft, which will make you feel more relaxed and secured. mailboxes

    ReplyDelete
  10. So could you confirm the latest working version - I am in need of a working convertor!
    TIA

    ReplyDelete
  11. Each Linux VPS Server has its own point of confinement with regards to the framework assets. It is to some degree restricted to about 1GB of RAM. wmware dedicated server

    ReplyDelete
  12. Among one of the finest pieces on the internet, freshening in its specificity.
    Wholesale Custom Printed Boxes

    ReplyDelete
  13. Hotmail Most of us had heard the name of Hotmail. First free email service in the early years of the 2000s. I am sure many of you had an account there too. Today we will talk about Hotmail and also will discuss how we can use the new version of this email service in 2020.

    ReplyDelete
  14. This is my first time visit to your blog and I am very interested in the articles that you serve. Provide enough knowledge for me. Thank you for sharing useful and don't forget, keep sharing useful info: hotmail.com

    ReplyDelete
  15. You can shop a extraordinary deal of time, attempt and money through the use of online present stores for sending provides to your family.www.teddyway.it

    ReplyDelete
  16. www.bbdd66.com 우리카지노사이트
    www.bbdd66.com/theking 더킹카지노
    www.bbdd66.com/sands 샌즈카지노
    www.bbdd66.com/first 퍼스트카지노
    www.bbdd66.com/yes 예스카지노
    www.bbdd66.com/super 슈퍼카지노
    www.bbdd66.com/gatsby 개츠비카지노
    www.bbdd66.com/33 33카지노
    www.bbdd66.com/world 월드카지노
    www.bbdd66.com/merit 메리트카지노

    ReplyDelete
  17. www.omgab.com 우리카지노사이트
    www.omgab.com/theking 더킹카지노
    www.omgab.com/sands 샌즈카지노
    www.omgab.com/first 퍼스트카지노
    www.omgab.com/yes 예스카지노
    www.omgab.com/super 슈퍼카지노
    www.omgab.com/gatsby 개츠비카지노
    www.omgab.com/33 33카지노
    www.omgab.com/world 월드카지노
    www.omgab.com/merit 메리트카지노

    ReplyDelete
  18. www.omgqq.com 우리카지노사이트
    www.omgqq.com/thekingcasino 더킹카지노
    www.omgqq.com/sandscasino 샌즈카지노
    www.omgqq.com/firstcasino 퍼스트카지노
    www.omgqq.com/yescasino 예스카지노
    www.omgqq.com/supercasino 슈퍼카지노
    www.omgqq.com/gatsbycasino 개츠비카지노
    www.omgqq.com/33casino 33카지노
    www.omgqq.com/worldcasino 월드카지노
    www.omgqq.com/merit 메리트카지노

    ReplyDelete
  19. www.omgka.com 우리카지노사이트
    www.omgka.com/theking 더킹카지노
    www.omgka.com/sands 샌즈카지노
    www.omgka.com/first 퍼스트카지노
    www.omgka.com/yes 예스카지노
    www.omgka.com/super 슈퍼카지노
    www.omgka.com/gatsby 개츠비카지노
    www.omgka.com/33 33카지노
    www.omgka.com/world 월드카지노
    www.omgka.com/merit 메리트카지노

    ReplyDelete
  20. This comment has been removed by the author.

    ReplyDelete
  21. This comment has been removed by the author.

    ReplyDelete
  22. Got stuck in that but figured it out. thanks
    Gmail Login

    ReplyDelete
  23. This comment has been removed by the author.

    ReplyDelete

  24. At about 18 months, children نقاط عطف رشدی کودکان تا یک ‌سالگی! begin to understand symbols. This means the relationship of objects and their meanings. Children may grow at different speeds, but at this age, their developmental milestones in understanding include the following that affect the behavior of a one-year-old.

    ReplyDelete
  25. Pregnancy screening is a set of pregnancy tests and ultrasounds that are performed for all pregnant mothers to check the fetus for some https://www.hlife.ir/1399/11/09/prenatal-tests/ inherited diseases and fetal abnormalities and to ensure its health. If the pregnant mother is in the high-risk category in these tests, other specialized tests will be performed for her definitive diagnosis so that appropriate treatment can be performed, such as abortion.

    ReplyDelete
  26. Do not forget that you should see a doctor with your spouse for pregnancy counseling. The advice given in the pregnancy counseling session is not https://fardayekhoob.ir/%d9%85%d8%b4%d8%a7%d9%88%d8%b1%d9%87-%d9%82%d8%a8%d9%84-%d8%a7%d8%b2-%d8%a8%d8%a7%d8%b1%d8%af%d8%a7%d8%b1%db%8c-%da%86%d9%87-%d8%a7%d9%87%d9%85%db%8c%d8%aa%db%8c-%d8%af%d8%a7%d8%b1%d8%af%d8%9f/ meant to be exclusive to the woman, but the man must do something.

    ReplyDelete
  27. Linux OS is amazing i liked it did any one mail me in gmail login!

    ReplyDelete
  28. Six-figure prizes aren’t 먹튀사이트 먹튀프렌즈 assured, but quarter-million dollar payouts are frequent with Reels & Wheels. Slots.lv is home to 195+ traditional, three-reel slot machines, all of which you can find a way to|which you'll} play with out spending a penny. If you’re here to play slots for real money too, Ignition’s welcome bonus won’t disappoint. Our immersive new game recreates the feel of a land-based casino for gamers, allowing them to position bets even after the spin was done. Choose on-line slots with essentially the most appropriate volatility for you. We hope this information helped you resolve which casino websites with free slot machine games listed above are perfect for you.

    ReplyDelete
  29. But, be wary since many fraudsters specifically target entry-level positions that may be fulfilled from a distant location. Don't send money to anybody using a gmail login address.

    ReplyDelete
  30. your blog is one of the best blog kindly share about yahoo mail

    ReplyDelete
  31. The deletion of a hotmail account is an irreversible process that has to be approached with extreme care.

    ReplyDelete
  32. Where to Look for a gmail Account Even though coming up with a name for a Gmail account can be hard, it's easy to make a list of possible email addresses by doing some research.

    ReplyDelete
  33. It was first called hotmail.com, with the "Hot" standing for "Hypertext Transfer Protocol," because it was the first web service to support HTML.

    ReplyDelete
  34. msn hotmail is a site that collects and republishes content from other sites, such as Newsweek, the Washington Examiner, Vox, or anyone else.

    ReplyDelete
  35. Good morning. I can confirm that you may or may not have to activate office 365 login again after reinstalling it on a computer that crashed. This depends on how you got the software in the first place.

    ReplyDelete
  36. With gmail.com built-in features, it's easy to link several accounts and email addresses.

    ReplyDelete
  37. It would seem that rediffmail has reached the end of its useful life as a personal email service provider.

    ReplyDelete
  38. Email functionality for the earlier, free versions of aol mail Desktop will be discontinued at some time in the future.

    ReplyDelete
  39. Your words have a significant impact on your readers, whether they be thought-provoking assessments, helpful how-to guides, or touching personal experiences. hotmail login

    ReplyDelete
  40. The lightning-fast loading time guarantees a seamless and easy browsing experience. hotmail

    ReplyDelete
  41. I am really very happy to visit your blog. Now I am found which I actually want. If you are looking for Yahoo Mail
    Hotmail Login
    Outlook Signup

    ReplyDelete
  42. Stumbled across your blog and your post is like a cozy cup of tea on a rainy day. It's warm and inviting. Can't wait for more cozy moments on your blog!
    hotmail

    ReplyDelete
  43. Department of Public facebook login and Town & Country Planning - Guestbook - Results from #2325

    ReplyDelete