Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Thursday, 4 April 2013

How to convert shell script into batch file

Quite a number of programmers learned scripting on a PC running DOS. Even the crippled DOS batch file language allowed writing some fairly powerful scripts and applications, though they often required extensive kludges and workarounds. Occasionally, the need still arises to convert an old DOS batch file to a UNIX shell script. This is generally not difficult, as DOS batch file operators are only a limited subset of the equivalent shell scripting ones.


Batch file keywords / variables / operators, and their shell equivalents

Batch File Operator Shell Script EquivalentMeaning
% $ command-line parameter prefix
/ - command-line parameter prefix
\ / directory path separator
== = (equal-to) string comparison test
!==! != (not equal-to) string comparison test
| | pipe
@ set +v do not echo current command
* * filename "wild card"
> > file redirection (overwrite)
>> >> file redirection (append)
< < redirect stdin
%VAR% $VAR environmental variable
REM # comment
NOT ! negate following test
NUL /dev/null "black hole" for burying command output
ECHO echo echo (many more option in Bash)
ECHO. echo echo blank line
ECHO OFF set +v do not echo command(s) following
FOR %%VAR IN (LIST) DO for var in [list]; do "for" loop
:LABEL none (unnecessary) label
GOTO none (use a function) jump to another location in the script
PAUSE sleep pause or wait an interval
CHOICE
case or select

menu choice
IF if if-test
IF EXIST FILENAME if [ -e filename ] test if file exists
IF !%N==! if [ -z "$N" ] if replaceable parameter "N" not present
CALL source or . (dot operator) "include" another script
COMMAND /C source or . (dot operator) "include" another script (same as CALL)
SET export set an environmental variable
SHIFT shift left shift command-line argument list
SGN -lt or -gt sign (of integer)
ERRORLEVEL $? exit status
CON stdin "console" (stdin)
PRN /dev/lp0 (generic) printer device
LPT1 /dev/lp0 first printer device
COM1 /dev/ttyS0 first serial port

Batch files usually contain DOS commands. These must be translated into their UNIX equivalents in order to convert a batch file into a shell script.


Hope this will help you.......
Enjoy :)
 

Monday, 4 March 2013

How to install Java 7 in Ubuntu


Java is a programming language and computing platform first released by Sun Microsystems in 1995. It is the underlying technology that powers state-of-the-art programs including utilities, games, and business applications. Java runs on more than 850 million personal computers worldwide, and on billions of devices worldwide, including mobile and TV devices.





Ubuntu is Fast, secure and stylishly simple, the Ubuntu operating system is used by 20 million people worldwide every day.









Prepare your Ubuntu

First you need to remove previous openjdk  version from your system, for this run the following command from your terminal

sudo apt-get purge openjdk*

If you installed java 7 from any other PPA and you are having problem with java then you have to do following steps before installing the PPA menctioned here

sudo rm /var/lib/dpkg/info/oracle-java7-installer*
sudo apt-get purge oracle-java7-installer*
sudo rm /etc/apt/sources.list.d/*java*
sudo apt-get update


Install java 7 in ubuntu 12.04

Open the terminal and run the following commands

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer 



Enjoy Coding ....... :)
Plz share your comments .....

Tuesday, 26 February 2013

Apache2 + Passenger Installation for rails on Ubuntu

There are some steps to install and configure apache2 & phusion passenger

To install Apache web server and its documentation & utilities on Linux machine using following commands

sudo apt-get install apache2




To Check the installation, Open web browser and type localhost or 127.0.0.1
It will look like this.

If you are using rvm, goto appropriate ruby version using rvm use 1.9.2(i'm having ruby version 1.9.2) and install passenger gem


gem install passenger

To install apache2 module in passenger type

passenger-install-apache2-module



If all depandencies are fullfilled, it will install otherwise it will give list of command you have to install to run passanger.

Snapshot of asking for dependencies. There are following dependencies.




Friday, 22 February 2013

RVM Installation on Ubuntu

Ruby Version Manager (RVM) makes it ridiculously easy to install and switch between multiple Ruby versions on OS X and Linux.

This tutorial  is only for Ubuntu

Set up Git
Download and install the latest version of Git with Synaptic.

I suggest you install git-core, git-gui, and git-doc.

sudo apt-get install git-core








Install RVM

You could go out and install Ruby from source yourself, but I recommend installing it instead using the Ruby Version Manager (RVM), for installing RVM first you have to install curl

sudo apt-get install curl

Then, install RVM following the instructions on the RVM website. Or follow our instructions.

bash < <(curl -sk https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)



echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc


source ~/.bashrc

Now you can see the rvm version by typing

rvm -v

Wooohoo ! RVM is installed.


Install Ruby


Before installing Ruby, first you have install the dependencies by typing the following command

sudo apt-get install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev autoconf libc6-dev libncurses5-dev automake libtool bison subversion

Now you can use use rvm to download, compile, and install Ruby by the command.

rvm install 1.9.3

rvm use 1.9.3 -default

The first command (rvm install) triggers the download/compile/install process, and installs Ruby and its gems under ~/.rvm, safely away from everything else on your system. The second command (rvm use) sets the 1.9.3 version of Ruby as the active default.

You can verify 1.9.3 is available by typing

ruby -v

Install Rails

After setting up ruby, we have to install Rails framework by typing

gem install rails -v 3.2.6

After setting up ruby, we have to install Rails framework by typing

rails -v










Thursday, 21 February 2013

Ubuntu for Android

Canonical is about to launch Ubuntu for Android. Now Carry just the phone, and connect it to any monitor to get a full Ubuntu desktop with all the native apps you want, running on the same device at the same time as Android. Magic. Everything important is shared across the desktop and the phone in real time. isn't it fun ?




It’s a lightweight way to be – everything seamlessly available with the right interface for the right form factor, with no hassles syncing. It just works, the way Ubuntu should. Lots of work behind the scenes to make both systems share what they need to share, but the desktop is a no-compromise desktop.

This isn’t the “Ubuntu Phone”. The phone experience here is pure Android. This announcement is playing to a different story, which is the convergence of multiple different form factors into one most-personal device. Naturally, the most personal device is the phone, so we want to get all of these different personalities – phone, tablet and desktop – into the phone. When you need a desktop, you connect up to a screen and a keyboard. When you need a tablet, you dock to some very elegant glass.




Just for fun, Canonical integrated the Ubuntu TV experience too – so this isn’t just a desktop in your pocket, it’s a media centre too.