Tuesday, August 17, 2010

Execute commands on remote machines non-interactively using ssh with expect

Expect is a program that "talks" to other interactive programs according to a script. Following the script, Expect knows what can be expected from a program and what the correct response should be. An interpreted language provides branching and high-level control structures to direct the dialogue. In addition, the user can take control and interact directly when desired, afterward returning control to the script.

Expectk is a mixture of Expect and Tk. It behaves just like Expect and Tk's wish. Expect can also be used directly in C or C++ (that is, without Tcl). See libexpect(3).

The name "Expect" comes from the idea of send/expect sequences popularized by uucp, kermit and other modem control programs. However unlike uucp, Expect is generalized so that it can be run as a user-level command with any program and task in mind. Expect can actually talk to several programs at the same time.

For example, here are some things Expect can do:

        * Cause your computer to dial you back, so that you can login without paying for the call.
        * Start a game (e.g., rogue) and if the optimal configuration doesn't appear, restart it (again and again) until it does, then hand over control to you.
        * Run fsck, and in response to its questions, answer "yes", "no" or give control back to you, based on predetermined criteria.
        * Connect to another network or BBS (e.g., MCI Mail, CompuServe) and automatically retrieve your mail so that it appears as if it was originally sent to your local system.
        * Carry environment variables, current directory, or any kind of information across rlogin, telnet, tip, su, chgrp, etc.

There are a variety of reasons why the shell cannot perform these tasks. (Try, you'll see.) All are possible with Expect.

In general, Expect is useful for running any program which requires interaction between the program and the user. All that is necessary is that the interaction can be characterized programmatically. Expect can also give the user back control (without halting the program being controlled) if desired. Similarly, the user can return control to the script at any time.

Example:
Make sure expect is installed on the system.

In this script df will be the command executed on remote hosts

-------------------------------------------------------------------------------
#!/bin/bash
USER=$1
HOST=$2
PASS=$3

VAR=$(expect -c "
spawn ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $USER@$HOST
expect \"password:\"
send \"$PASS\r\"
expect \"\\\\$\"
send \"df -h \r\"
expect -re \"$USER.*\"
send \"logout\"
")

echo "==============="
echo "$VAR"
-------------------------------------------------------------------------------
#Excecute the Script#
#./ScriptName  UserName HostName Password
-------------------------------------------------------------------------------

Wednesday, August 11, 2010

Web Conferencing for Distance Education

BigBlueButton is an open source web conferencing system for distance education.
BigBlueButton (BBB) enables universities and colleges to deliver a high-quality learning experience to remote students. BigBlueButton supports sharing of slides (PDF and PPT), whiteboard, chat, video, voice (using Asterisk), and desktops. It is built using over fifteen open source components, runs on Windows, Linux, Unix, and Mac computers.

See -> http://code.google.com/p/bigbluebutton/

Popular Opensource Application and Technology

Webserver: Apache, Nginx, Lighttpd, Cherokee. 


Database Server: MySql, PostgreSql, MariaDB, Percona server, Firebird.

NoSQL Databases: MongoDB, CouchDB, Cassandra

Mail Server: Qmail, Postfix, Exim, Zimbra, Sendmail.

Application Server: Tomcat, Jboss, GlassFish.


eCommerce: Magento, VirtueMart, PrestaShop, Zen Cart, osCommerce, UberCart, Broadleaf Commerce, OFBiz, Satchmo, Bots.

Content management: Wordpress, Drupal, Media Wiki, Joomla, Alfresco, SilverStripe, Plone, Knowledge Tree, DSpace, Apache Roller, LifeRay.


Content Filtering:  Squid, DansGuardian.

Messaging: DimDim, Asterisk, OpenFire, Mumble, Vanilla forum, StatusNet, Zarafa, Scalix, RoundCube, OpenEMM.

Business:  OpenBravo, SugarCRM, vTiger CRM, Open HRM, Apache OFBiz, GLPI.


Monitoring: Nagios, OpsView, GroundWork, Cacti, ZenOSS, Hyperic, Zabbix, OpenNMS.

Infrastructure: OpenLDAP, Radius.

Development frameworks: Symfony, Django, Zope, TurboGears, jBoss, Ruby on Rails, CakePHP, Codeigniter, Zend.


Management: RedMine, Moodle, eBox, ISPConfig.


Data integration: Jasper BI, Pentaho, SnapLogic.


Backup: Amanda, Bacula.


IDS: Snort + Aanval, Snorby.


Virtualization: Proxmox VE, Xen-DTC, oVirt, enomaly, eucalyptus.


Thin-Cliets : openThinClient, LTSP server.


Bug Tracking System: Bugzilla, Mantis, Roundup.


Ticketing System : OTRS, osTicket
.

Cloud OS : eyeOS, Good OS.


Forum: phpbb, bbpress

Social networking: buddypress, elgg


Misc: Apache Solr, iFolder, IceCast, OpenVPN ALS.

List of free and open source software packages :  

http://en.wikipedia.org/wiki/List_of_free_and_open_source_software_packages

Wednesday, August 4, 2010

Simple Example to create a MySQL database and set privileges to a user

On a default settings, mysql root user do not need a password to authenticate from localhost. In this case, ou can login as root on your mysql server using:

$ mysql -u root


If a password is required, use the extra switch -p:

$ mysql -u root -p
Enter password:

Now that you are logged in, we create a database:

mysql> create database drupaldb;
Query OK, 1 row affected (0.00 sec)

We allow user amarokuser to connect to the server from localhost using the password amarokpasswd:

mysql> grant usage on *.* to drupaluser@localhost identified by 'drupalpasswd';
Query OK, 0 rows affected (0.00 sec) 

And finally we grant all privileges on the amarok database to this user:

mysql> grant all privileges on drupaldb.* to drupaluser@localhost ;
Query OK, 0 rows affected (0.00 sec) 

And that's it. You can now check that you can connect to the MySQL server using this command:

$ mysql -u drupaluser -p'drupalpasswd' drupaldb