C program to get the ascii string from a string

2012-07-25 1 min read C Programs
Example diagram of the printf function in the C programming language (Photo credit: Wikipedia) Lot of times, you would like to get the complete string in hex or ascii format and if you are one of them then this is something that will be helpful for you 🙂 Example output: lp-amita[d=~/bin]> ./ascii aamit String – aamit, Length – 5 String : aamit Hex : 0x61616d6974 Dec : 9797109105116 And the source code: Continue reading

Ubuntu setup – post installation script

2012-07-03 4 min read bash
My iPhone apps as of February 2010 (Photo credit: dougbelshaw) If you have done a new installation of Ubuntu or Fedora, then yuou know you have to search all kind of blogs to find out what all to install. So, here is a easier way to do that. Just run this script, it will install some applications which are mostly a “MUST” for all the installations. And the list of applications that are installed are : Continue reading

Array of all possible colors in bash script

2012-05-07 1 min read bash Learning
Sometime back, we had looked at using colors in bash script and here is a way to create a array of all the colors. #!/bin/bash - #=============================================================================== # # FILE: colorarray.sh # # USAGE: ./colorarray.sh # # DESCRIPTION: # # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- # NOTES: --- # AUTHOR: Amit Agarwal (aka), amit.agarwal@roamware.com # COMPANY: Roamware India Pvt Ltd # CREATED: 16/04/12 17:24:09 IST # Last modified: Mon Apr 16, 2012 05:39PM # REVISION: --- #=============================================================================== count=0 for i in 40m 41m 42m 43m 44m 45m 46m 47m do for l in 0 1 do echo -n " Continue reading

Display X applications from virtual terminals

2012-05-03 1 min read Fedora Gnome
GNOME Session plugin (Photo credit: David Siegel) Here is a script that can help you set the proper envirionment to start a gnome-shell from one of the terminals. #!/bin/bash - #=============================================================================== # # FILE: xenv.sh # # USAGE: ./xenv.sh # # DESCRIPTION: http://live.gnome.org/GnomeShell/Debugging # # # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- # NOTES: --- # AUTHOR: Amit Agarwal (aka), amit.agarwal@roamware.com # CREATED: 09/14/2011 04:45:31 PM IST # Last modified: Wed Sep 14, 2011 04:45PM # REVISION: --- #=============================================================================== gnome_session=$(pgrep -u $USER gnome-session) eval export$(sed's/\o000/\n/g;' < /proc/$gnome_session/environ |grep DISPLAY) eval export$(sed's/\o000/\n/g;' < /proc/$gnome_session/environ |grep XAUTHORITY) eval export$(sed's/\o000/\n/g;' < /proc/$gnome_session/environ |grep DBUS_SESSION_BUS_ADDRESS) So, once you have done that you have the correct environment to use the X display and thus you can start the gnome-shell as well or do any other fancy thing that you want 🙂 Continue reading

colors in bash scripts

2012-04-30 3 min read bash Fedora Learning
Colours (Photo credit: CherrySoda!) I have been trying to understand the color codes for bash for a pretty long time, but somehow never got time to understand this clearly. So this time around when I was writing a script to analyze some logs. I thought I will give it a go and finally understood some part of this. So, first we will start with this script. This is taken from here. Continue reading

Convert string to hex.

2012-04-13 1 min read C Programs
If you want to use snoop or tcpdump with advanced search in the packet, then you would need to convert the string to hex string. For this, either you can use a web search and find some web application to do that or you can use a simple C program like this 🙂 /* * ===================================================================================== * * Filename: ascii.c * * Description: ascii to dec * * Version: 1.0 * Ceated: 03/02/2012 12:08:49 PM * Revision: none * Compiler: gcc * * Author: Amit Agarwal (aka), amit. Continue reading

Tora installation on Fedora 16 with rpm

2012-02-09 1 min read Database Fedora
[][1]Image via Wikipedia Last article I talked about tora installation from the sources, but if that is too much for you then you can use this one liner: rpm -ivh "http://amit-agarwal.co.in/mystuff/tora-2.1.3-1.fc16.i686.rpm" But if you like the hard way out, then you can always try this. Related articles Unrar in Fedora… (gryphon143.wordpress.com) Fedora Utils just got easier (funsurf.wordpress.com) rpmorphan – deborphan for the rpm based distros. (amit-agarwal.co.in)
Older posts Newer posts