Bash
more_horiz
close

on 22nd September 2015 / by premshankar.pb
Converting the jpg to text is done by OCR(Optical character reading). There are lot of online OCR services available now. But these services set a limit in the input file size we are feeding. So the best option is to do conversion through the shell command. Here I explain the conversion using the shell commands. Convertion of image to text To convert the image to text, we are using tesseract OCR. For using tesseract we should install the tesseract in our system. For that use the code: sudo apt-get install tesseract-ocr The tesseact OCR will only process files with .tif format. So we should convert our image files to tif format. So we should need an image processing application. Here I use ImageMagick. For installing use the code: sudo apt-get install imagemagick After the successful installation, convert the image file to tif format. For that use command: convert 1.jpg foo.tif Now you have your tif file in your directory. Convert this tif to txt file. For that use command: tesseract foo.tif foo You will get a foo.txt file in your folder. Hope this helps. Please fell free to share your thoughts and doubts regarding this here. Bash Leave a reply Your email address will not be published. Required fields are marker *
more_horiz
close

on 01st September 2015 / by fazeela.ma
We have all User Interface germs, if there no UI for a particular process. We get into a great trouble. One such program that comes handy in such situation is command prompt. All might have terminated a running process from task manager, may not through command prompt. TOP Command Prior to terminating, first make sure which program need to be terminated. Every program have a machine name. To know the all the running processes along with its machine just type, top to the command prompt. Now you see a list of programs running. Select the program to be terminated. Lets say, web browser `Firefox` has to be shut down. For firefox its machine name is `Firefox` itself. All need to be done to kill firefox is, killall Firefox; There are many commands in terminal that could let us do many things much better, swifter and secured than UI. You may also look into other articles related to Linux commands over here. Linux Terminal Bash Ubuntu Leave a reply Your email address will not be published. Required fields are marker *
more_horiz
close

on 14th August 2015 / by sarika.k
This article will help you to declare and print a variable using programming basic, intermediate shell scripts and how to use Bash script to copy files in Ubuntu. Actually, Bash is very simple and flexible UNIX shell scripting language which need some permission while executing. Here I'm going to share some tips of Bash Script. It does not intend to be an advanced document. To clear your doubts or share your information about Bash, you can contact us. Using Bash script we can declare and print a variable using, #!/bin/bash # declare STRING variable STRING="Hello World" #print variable on a screen echo $STRINGTo copy files using Bash script, we can use, #!/bin/bash srcdir="~/Desktop/bash_script" dstdir="~/Desktop/bash_new/" d=$(date +%m%d%y) srcfile="hello_world.sh" cp $srcdir $dstdir #for srcfile in ${srcdir} #do # dstfile=$(basename $srcfile) # dstfile=${dstfile/\./${d}\.} # cp $srcfile $dstdir/$dstfile #doneDo you need more information about Bash script or commands, checkout now. Bash Ubuntu Leave a reply Your email address will not be published. Required fields are marker *
more_horiz
close

on 22nd May 2015 / by fazeela.ma
Command line provides a platform to that takes input from keyboard to interact with the operating system. In Linux Operating System's, the Command line is often referred to bash. MySQL in Command Line About 90% of us would have created database, and its table using phpmyadmin user interface. How would it be if we can create database, tables etc. through bash ? Sure to add as an asset to our knowledge base. So lets get started. Follow up the instructions below before you explore sql commands in bash. Now lets assume we are good to go with our pre requesites installed. apt-get install mysql-client;apt-get install mysql-server; After installing, lets get started with the basics, We need to switch on to mysql mode, open your terminal. Either open using keyboard shortcut Ctl+Alt+t or Click on dash home, type terminal and select. Login mysql -u username -p; Enter the password on prompting. Replace username with yours. mysql> Everything went right for you, if you get the above to the left corner of bash. Or else something went wrong in enabling mysql, go back to make corrections or ask for technical support. Create database mysql> CREATE DATABASE database_name; Lets assume the name of our database as train. Query would become Enter the password on prompting. Replace username with yours. mysql> CREATE DATABASE train; Query OK, 1 row affected (0.03 sec) Create a user Create a user without password. mysql> CREATE USER 'username'@'hostname'; Lets assume the name of the new user as me. Query would become mysql> CREATE USER 'me'@'localhost'; Query OK, 0 rows affected (0.10 sec) Create a user with password mysql> CREATE USER 'username'@'hostname' IDENTIFIED BY 'password'; Lets assume the name of the new user and password as me. Query would become mysql> CREATE USER 'me'@'localhost' IDENTIFIED BY 'me'; Query OK, 0 rows affected (0.10 sec) Create a table mysql> USE database_name;mysql> CREATE TABLE table_name (column_name1 column_type1, column_name2 column_type2, ); Query would become, USE train; Database changed mysql> create table train_details (Id int(11), Name char(20), StartingStation VARCHAR(20)); Query OK, 0 rows affected (0.29 sec) Insert value into table mysql> INSERT INTO TABLE_NAME (column_name1, column_name2, column_name3) VALUES (coloumn_value1, coloumn_value2, coloumn_value3); Query would become, mysql> INSERT INTO train_details(Id, Name, StartingStation) VALUES (1, 'Shadabdi Express', 'Aluva' ); Query OK, 1 row affected (0.08 sec) Update a table mysql> UPDATE table SET coloumn_name = coloumn_value, WHERE conditions; Query would become, UPDATE train_details SET StartingStation = 'Ernakulam' WHERE Id =1; Query OK, 1 row affected (0.08 sec) Rows matched: 1 Changed: 1 Warnings: 0 Delete a value from table mysql> DELETE FROM table_name WHERE column_name = coloumn_value; Query would become, mysql> DELETE FROM train_details WHERE Id = 1; Query OK, 1 row affected (0.04 sec) Table Structure mysql> DESC table_name; Query would become, mysql> DESC train_details; +-----------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------+-------------+------+-----+---------+-------+ | Id | int(11) | YES | | NULL | | | Name | char(20) | YES | | NULL | | | StartingStation | varchar(20) | YES | | NULL | | +-----------------+-------------+------+-----+---------+-------+ 3 rows in set (0.00 sec) Drop a tablemysql> DROP table table_name; Query would become, mysql> DROP table train_details; Query OK, 1 row affected (0.08 sec) Delete a databasemysql> DROP DATABASE train; Query would become, mysql> DROP DATABASE train; Query OK, 1 row affected (0.08 sec) Export a databasemysql> mysqldump -u username -p password database_name > sqlfile_name.sql; Query would become, mysql> mysqldump -u root -p train > train.sql; Query OK, 1 row affected (0.08 sec) Import a databasemysql> mysqldump -u username -p password database_name Query would become, mysql> mysqldump -u root -p train There is another method to do this, the one i prefer most mysql> USE DATABASE database_name; mysql> SOURCE pathtosqldfile.sql The query will become, mysql> USE DATABASE train; mysql> SOURCE /home/zyx/Projects/train.sql Query OK, 1 row affected (0.08 sec) For me it was more like a nightmare to work on command prompt, once we learn the way to work on commad prompt, i bet we insist ourselves to do things on bash. The commands we used are all mysql queries. Bash can perform a task much faster than using Graphical Interface. It also allow access to more commands and scripts. Bash BASH Scripting Leave a reply Your email address will not be published. Required fields are marker *
more_horiz
close

on 11th March 2015 / by fazeela.ma
Ever since we have used computer, all might have heard of command line tool. Most commonly called bash. Command line is capable of taking input and outputting its results from and to computer. One of the features command line offers is it lets the users to create their own instructions. In this article we will take a tour through the steps on creating our own bash command. Create custom command on Bash This feature comes hand full when we are executing 2 or 3 everyday commands to do a single functionality. Let me make the picture more clear. I don't know how many would have created a virtual host. Here I'm considering the virtual host as the scenario. On creating virtual host, include the ip address along with the host name in /etc/hosts/ file. So let's get started. [Hint: Assuming you are using Linux OS] For performing with task one must execute the following tasks, Go to /etc folder using cd /etc folder. Now open the hosts file to edit by sudo nano hosts. So, why we do this all the time, when ever we want to add a newly created host to hosts file. I have created a custom command for doing this by executing a single command. The steps to create these commands would be a mess, but I bet this is something very useful. Lets start creating our own command, Open up the terminal, type the commandsudo nano Now a plain space must appear in your terminal. Now enter the following #!/bin/bash #command to open /etc/hosts file sudo nano /etc/hosts Let me explain, The symbol you see is often referred as 'HashBang' which points to /bin/bash which means the command we've entered in this case sudo nano /etc/hosts runs using bash program. Second line is the comment for the instruction for later reference. Third line refers to the set of instructions to execute. . Save the file with the name of your costum command you intend to make. Lets name it as 'ghost' in short of go to hosts file. Now If you try to execute the command we have created, let's say ghost, you can notice that the 'command not found'. As a next step, move the file to /usr/bincp -i ghost /usr/bin Here we are copying ghost to /usr/bin folder Now try to type ghost on bash, you we see 'permission denied' error. From above we must get a clue, that the file we created is not executable. So lets move to give the file executing permissionchmod +x ghost Now make a run to execute your command on terminal. It must open up the hosts file in etc folder. Bash is providing a universe of pre defined commands. Lets make it our own by putting some effort in customizing. By this way, we can create our own commands for everyday combination of commands we use in one step. Bash can do tasks faster than Graphical Interface. It also allow access to more commands and scripts. Bash BASH Scripting Leave a reply Your email address will not be published. Required fields are marker *
more_horiz
close

on 11th December 2014 / by sandeep.sasikumar
In Ubuntu, new applications are usually available as deb packages. Although Ubuntu comes packaged with gui package management tools like synaptic, the command line provides a much faster way. Read on to know how to manage deb packages in Ubuntu from the command line using apt-cache. 'apt-cache search' - Used to search for repositories. If you want to install a package and if you want to search for it i.e. check whether it is a valid package, you can use apt-cache search. For example apt-cache 'package-name' Suppose you want to search for the package skype apt-cache search skype pidgin-skype - Skype plugin for libpurple messengers pidgin-skype-dbg - Skype plugin for libpurple messengers (debug symbols) earcandy - Sound level manager for PulseAudio skype - Skype 'apt-cache search' - Used to search package using package description. That is, if you want to install phpmyadmin, you can search for it in'apt-cache search php'. This will list all the packages relating to php, including phpmyadmin 'apt-cache show 'package-name' : To display the basic information about a package.' For example : You can try this by going through the command 'apt-cache show skype' This will list all the details the package skype You will get something like this Package: skype Status: install ok installed Priority: extra Section: non-free/net Installed-Size: 28722 Maintainer: Skype Technologies Architecture: i386 Version: 2.2.0.35-1 Depends: libasound2 (>> 1.0.17), libc6 (>= 2.7-1), libgcc1 (>= 1:4.3), libqt4-dbus (>= 4.4.3), libqt4-network (>= 4.4.3), libqtcore4 (>= 4.4.3), libqtgui4 (>= 4.4.3), libstdc++6 (>= 4.3), libx11-6, libxext6, libxss1, libxv1 Conffiles: /etc/dbus-1/system.d/skype.conf d09fd2adb2487dbaaeb97c43f6cdc08d Description: Skype . Skype is software that enables people around the world to connect via instant message, audio conferencing, and video phone. Millions of individuals and businesses use Skype to make free video and voice calls, send instant messages and share files with other Skype users. Everyday, people also use Skype to make low-cost calls to landlines and mobiles. . * Make free Skype-to-Skype calls to anyone else, anywhere in the world. * Call to landlines and mobiles at great rates. * Group chat with up to 200 people or conference call with up to 25 others. * Free to download. Ubuntu Bash GNU/Linux Leave a reply Your email address will not be published. Required fields are marker *
more_horiz
close

on 11th December 2014 / by sandeep.sasikumar
This is a small shell script that will help to detect ip conflicts in a network. The notify-send command, used in the script, will enable a popup if any ip conflict is detected. You can run this script in cron. You will get a notification as pop up, if there is any ip conflict in the network. #!/bin/bash # Script to check ipconflict # Grep the word "Dup" and enable a pop up to show that there is ip conflict sudo arp-scan -I eth2 -l | grep DUP if [[ $? == 0 ]]; then notify-send "Ip-conflict detected" fi Shell Scripting Bash GNU/Linux Leave a reply Your email address will not be published. Required fields are marker *
more_horiz
close

on 08th December 2014 / by sandeep.sasikumar
Nmap(Network-mapper) is an open source tool that is pretty useful for networking scanning. This tool provides various options that are useful for carrying out security audits. Nmap is a powerful tool used to check the network inventory, host uptime etc. If you are a GNU/LINUX administrator, you may find the following 10 Nmap commands extremely useful Some of the useful Nmap commands are as mentioned below: Scan a single host in the network. nmap [IP-address of the host] Scan multiple hosts in the network. nmap [Hostname of the host] Scan whether a host is firewall protected nmap -sA [IP-address of the host] Scan whether a network is firewall protected nmap -sA [IP-address series of the network] Scan a full network and find out which devices are up and running nmap -sP [IP-address series of the network] Fast scan options nmap -F [IP-address series of the network] Display all open ports and also display the number of closed ports nmap --open [IP-address of the host] Scan specific ports nmap -p [port-number] [IP-address of the host] Scan the operating system of remote host nmap -O [IP-address of host] Scan the service version number of remote host nmap -sV [IP-address of the host] Networking Bash GNU/Linux Leave a reply Your email address will not be published. Required fields are marker *
more_horiz
close

on 08th December 2014 / by sandeep.sasikumar
If you are using GNU/Linux, you are likely to be familiar with the command line, usually Bash, which of course means that you would be working with tar archives (tape archives). The need to extract a single file from a tar archive/file is a common situation faced by bash users. Read on to know how to do it. The following commands will extract the single file from the tar, tar.gz, tar.bz2 files. To extract a single file from a tar file : tar -xvf filename.tar filename To extract a single file from a tar.gz file : tar -xvf filename.tar.gz filename To extract a single file from a tar.bz2 file : tar -xvf filename.tar.bz2 filename Here 'filename' refers to the single file that is required from the large tar, tar.gz or tar.bz2 file. Each of these commands will extract the single file needed from the large file. Linux Tips Bash GNU/Linux Leave a reply Your email address will not be published. Required fields are marker *
more_horiz
close

on 26th February 2014 / by webmaster
Lines of code is typically indicative of effort that goes towards software development. So how do you count lines of code in your PHP application (or for that matter any specific types of files in any application). You can't manually open and count files, that would be a big waste of time. The *nix shell has a powerful set of tools that can help you count lines without having to do it manually. find . -name "*.php" | xargs wc -l | awk '{print $1}' | awk '{total = total + $1}END{print total}' The find command finds files named *.php (you can replace this with other patterns or sets of patterns with -o and -a). These files are passed to wc using xargs. wc prints out the list of files with the number of lines in each. The tabular output is then processed using awk to separate out just the column of line counts. This is then again processed using a bit of awk scripting. I hope you got the general idea here on how these commands work to give you the number of lines of code in your PHP files. Happy coding. Shell Scripting Bash BASH Scripting Leave a reply Your email address will not be published. Required fields are marker *