Skip to main content

Posts

Showing posts from June, 2010

VLAN implementation using NS2

http_proxy in ubuntu

If you are working in the internet with ubuntu, you may need some software to be installed before it is being used actually. If you install ubuntu with a live CD, you will not have VLC Media player, etc. Proxy setup needed to install/update software in ubuntu 1. proxy support for Synaptic package manager Go to Settings-> preferences –> Network Tab, click manual proxy configuration and then set the proxy ip and port 2. proxy support for apt-get Open the file /root/.bashrc and type the following line export http_proxy=http://username:password@host:port/ If your proxy server does not have username/password combination then include the following line export http_proxy=http://host:port/ for example, export http_proxy=http://192.168.0.10:808/ (NB: .bashrc file is available for all the users of ubuntu, for example if the Linux user login name is “pradeepkumar” then there will be a .bashrc file at /home/pradeepkumar/ , but setting the http_proxy in those files wil

Printing Environmental Variables and CPU Time using C

  To print the environmental variables of Linux using C. To print the system uptime and system idle time. Requirements : GCC compiler Suse Linux (Sun V20Z Linux Server) Theory: Linux provides each running program with an environment . The environment is a collection of variable/value pairs. Both environment variable names and their values are character strings. By convention, environment variable names are spelled in all capital letters. You're probably familiar with several common environment variables already. For instance: USER contains your username. HOME contains the path to your home directory. PATH contains a colon-separated list of directories through which Linux searches for commands you invoke. DISPLAY contains the name and display number of the X Window server on which windows from graphical X Window programs will appear. Program: //Printing the Execution Environment #include <stdio.h> /* The ENVIRON variable contains the environment. */ extern char** environ; i

File Handling using Shell Scripts

File handling using Shell Scripts to prepend a line to a file to develop a temporary file name generator to compare two files Requirements:     Suse Linux, BASH Scripting Program (a) Prepending a line to a file   #!/bin/bash # prepend.sh: Add text at beginning of file.   E_NOSUCHFILE=65   read -p "File: " file # -p arg to 'read' displays prompt. if [ ! -e "$file" ]     then # Bail out if no such file.     echo "File $file not found."     exit $E_NOSUCHFILE fi   read -p "Title: " title cat - $file <<<$title > $file.new echo "Modified file is $file.new" exit 0   (b) to develop a temporary file name generator #!/bin/bash # tempfile-name.sh: temp filename generator BASE_STR=`mcookie` # 32-character magic cookie. POS=11 # Arbitrary position in magic cookie string. LEN=5 # Get $LEN consecutive characters. prefix=temp # This is, after all, a "temp" file. # For more &q