Ananth's Blog - page 11

Posts

Creating and Deleting Folders/Directories using C

This program will create 100 folders from where it is executing. Then after the first half of the program it will delete those folders from the directory.


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.

Simple DIP threshold animation using Matlab


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..

How to use variable from bash to use in awk?

If you want to use your variable from script inside awk, do the following

column=2
ps | awk '{print $var}' var=$column


or

name="Hello"
echo $name | awk '{print var}' var=$name