Skip to main content

Posts

Showing posts from 2014

Featured Post

Product Design of a 4 wheel differential drive robot

Chat/Messenger program using c

Messages send through server program will be displayed in the client side. Port used is 10000. You can change the ip address of server in the client side program. Will update the program to include more features. The program is intended to use in Linux platform. (Compiler  used is gcc). Server Client

Socket Programming in C

This is a simple server client program I wrote in C while learning. The program lacks several error checking. But it works and is simple to understand. Use this code only for learning process. The server send Hello World and the client will print it in the screen. Server program should run first and then the client program in a different terminal. Use this code in a Linux platform. Server Client

Flooding RAM ( C )

This program will dynamically allocate memory and shows the amount of memory it uses. When heap is empty it will show Memory Full. The memory will be freed once you close the program (No harm by the way!). The rate at which memory is allocated is small (1 Kb per each iteration) so you can see at which point heap becomes empty.

Automating scripts using expect

Expect is one way to automate your scripts by expecting what the output may be. For example you want to create a script that helps you to login to a telnet session and enter your login and password for you. Here is the simple example which helps you to do it. Above example will login to your router and enter your username and password and list all the possible commands using ? and then let you to interact with using interact command. You can automate anything for example applications, ssh etc..

Linux command awk extract anything

Awk is pretty use full when you are writing automatic scripts to do your jobs. Some simple examples of how we can use awk are given below ps | awk '{print $1}' It will print first column of ps command.  If you want to print second column also write ps | awk '{print $1 $2}' Output seems to be pretty crowded? Add a simple space by ps | awk '{print $1 " " $2}' Want to limit it display only second line? ps | awk ' NR==2{print $1 " " $2}' Want to exclede first row? You can do it by ps |awk 'NR !=1{print  $1 " " $2}' Similarly you can print rows greater than a value by ps |awk 'NR >1{print  $1 " " $2}' You can extract virtually anything using awk... Feel free to explore every options. Type man awk or awk --help to explore other options. Feel free to comment also... :) This site has some good examlpes.

Pass output of one command to argument of other

Well Linux is famous for combining things in power full ways in which anything is possible from a command line. The real fun of Linux came when you start focusing on terminal to do everything... It's possible to pipeline commands in terminal. Also it's possible to pass output of something as an argument of other. For example you can ping to your own external ip by ping $(curl -s  curlmyip.com) curl curlmyip.com returns you ip address. This address is passed to  the telnet as an argument. Whatever you put between $( and ) will execute as if it is a bash command.

How to know external IP address from Linux terminal?

ifconfig displays only local ip address of your system. If your system is directly connected to internet then it will be your external ip address. It may not be the case always. Because you will be behind a router or a modem. You can know the external IP address by going to www.whatismyip.com or www.ipecho.net . If you want to know it from a terminal type curl curlmyip.com What curl do is it fetches the content of the link to the terminal. There are also several other websites that offers this same service. Some of them are listed below. curl  ipecho.net/plain curl myexternalip.com/raw curl curlmyip.com curl ifconfig.me/ip curl icanhazip.com curl ip.appspot.com

How to set dns address in android phones?

Ever wondered how setup dns address in android phones. You can do it if your phone is rooted. You may have a terminal installed with busybox if your phone is rooted. Otherwise install a terminal and gain root permission by typing su Then list all the device dns entries using this command getprop | grep dns Then set the dns entries by the command setprop net.rmnet0.dns1  8.8.8.8 Here rmnet0.dns1 is given as an example. This may vary depending on which dns entry you have to choose. 8.8.8.8 is the googles dns server address. Replace it with your choice.

Testing NAT Port Forwarding and reverese NAT

For a long time I have been trying to configure port forwarding using NAT. But every attempt was futile...  Finally I found that my port forwarding works just fine. But it just appears to be not working because my router doesn't support reverse NAT. In this post I will show you guys how to test whether you configure your NAT correctly or not. (Read a detailed write up by shane. Link ) First make a port forwarding rule in your router say 1600. Download this little tool called simple internet tools. Install it and open port listener and select your internal IP(192.168.x.x). Then type your port number and press start listening. Go to this site  and check whether it says port is opened. If your connection is successful you will notice it in the port listener application. Then go to your browser and type your internet ip address. (You can find it from www.whatismyip.com) . Tnen type your port number after a colon. (116.211.22.12:1600). Your browser shows a webpage not available w

Ultrasonic Hover Input Device

This was my Bachelor Project. The project was selected for the Malayala Manorama Yuva Master Mind 2014. This is a video describing the project at the final round in the competition. About the project  The project is made possible by making use of ultrasonic sound to map the location of an object. This device enables an user to control the screen by hovering his/her hands above it. A 3D virtual space will be created and any hand movement in that space is directly mapped to the display. Group Members: Ananthakrishnan U S , Arun Raveendran , Alfred Do minic , Anju Dony

How to send AT commands?

For details about AT commands refer this link . If you are using windows you can use hyperterminal to communicate with any modem. In this case the GSM modem. Find a method to connect your GSM modem to the PC  (Refer this Link  ). You can use a USB2TTL converter to directly interface your GSM modem to PC. After interfacing the modem go to device manager and find the com port no: assigned to your GSM modem. After identifying the port number open hyperterminal. You need to download Hyperterminal or copy the files from windows XP. You can also use putty for this purpose.  Type a name and click OK. Then select the com port you are using and press ok. Change the boadrate to 9600(you can choose other also. Higher boadrates may not work with some GSM modem) and let other options remain unchanged. After that type AT and press Enter. If you get a response showing OK. Then everything is fine. As a default typed character are not shown in the terminal. You can enable this by goi

AT Commands

AT commands are used for communicating with a modem. AT is the abbreviation of ATtention commands. Every command start with AT. Some of the useful AT commands are listed below. You can call a number, attend a call, hang a call, send sms, read sms, and the list goes on with the features of a particular provider. Some commands are specific to some models. GSM modems can be bought and can be integrated to Micro-controllers or directly to PC. Following list may be helpful to hobbyist or others working on GSM modems for project works. AT The response will be OK. This means that the modem is up and ready. ATD94xxxxxxxx This command will initiate a voice call to the no 94xxxxxxxx. The semicolon indicates that it is a voice call. If you want to run any USSD codes like *123# for balance enquirey, do the same without semicolon. ATD*123# Other Call control commands Command Description ATA Answer command ATD Dial command ATH Hang up call   Sending an SMS.

How to hide and unhide files in Linux?

If you are new to linux OS, it's a common mistake to add a (.) in front of your files and suddenly the file disappears. In Linux filenames starting with a dot (.) are hidden. You can intentionally make a folder or file hidden by renaming it. mv filename .filename If you want to view you hidden files or folders, first go to the location where the file resides using cd command. cd /root/Desktop/ Then list all files and folders using ls command. ls -a If you want to permanently unhide then use mv command again. mv .filename filename

Linux: How to find your serial (any connected) device?

In Linux all devices that are connected to the system are listed in /dev If you connect your mouse to your system it will detect it as hidraw. Other serial devices will be named as tty0, tty1,etc. So if you connect a serial (any) device and you want to know it's name ( for ex: you want to connect it via minicom ), first go to /dev using cd /dev Then list the contents of folder using ls But it will be hard to figure out the name of your device from the long list. So here is a trick for it. Disconnect the device and type this in terminal. ls > removed.txt Connect your device again and type ls >connected.txt Your device's name will be on the connected.txt file. But how to know filter it? Compare both list and the odd one will be your device. Type this. diff removed.txt connected.txt You will get the name of your device.

Serial Port Communication in Linux using Minicom

First of all install minicom using apt-get install minicom or directly download the .deb package from  https://packages.debian.org/sid/minicom  and install it using dpkg -i <package name> After install type minicom -s to setup the minicom for using your serial port. Select Serial Port Setup and type A to select serial device. It will be shown as /dev/modem replace modem with  your serial device. Press Enter twice to save. You can also setup boadrate and all those stuff in the Serial Port Setup. After that you can save your configurations. Select Save Setup as. Then type a name and press enter to save it. If you wan't to open your configuration later, type minicom <configuration name>