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

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

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