This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Monday, January 7, 2013

Unix Lab Programming

 

 

 

 

  1. /*BASIC UNIX AND NETWORKING COMMANDS*/

 

 

 

BASIC UNIX COMMANDS

 

 

passwd:

 

            This command allows you to change your login password. You are propted to enter your current password, and then prompted (twice) to enter  your new password.

                          

 

OUTPUT:

 

[2mcaa17mca24~]$ passwd

 

changing password for user 2mcaa2

changing password for 2mcaa2

(current) UNIX password:

New UNIX password:

Retype new UNIX password.

 

passwd: all authentication token updated successfully.

 

 

cd:

 

            This command, as in DOS changes directories. You can use to represent the directory above the current directory.

 

syntax:   cd directory name

 

 

OUTPUT:

 

[2mcaa17@mca24~]$ cd khs

[2mcaa17@mca24~ khs]$

 

 

 

 

 

 


pwd
:

 

            This command tells you which directory you are currently working in, your home directory from anywhere, type cd~, however typing cd without the ~ also works on Linux system.

 

OUTPUT:

 

[2mcaa2@mca24~]$ pwd

/home/2mcaa2/khs

 

 

ls:

 

            This gives you listing of all files in a directory. You cannot tell which files are and which directories are.

 

 

OUTPUT:

 

arms.sh            fibb.sh             fibo.sh             reverse.sh

sqcu.sh                        sum.sh             swapping.sh

 

ls-f:

 

            This shows which files are normal files (they have no special symbols at the end), which are directories (they end in a/character), which are links (they end in a @ symbol) and which are executables (they end in a *character). There special symbol are NOT part of the file name.

 

OUTPUT:

 

.creat.c.swo     .zshre               .                       ..                      .bash_logout

.bashrc             .swp                 .add.sh.swp     .swm.sh           swapping.sh   

.creat.sh.swp   .fork.c.swp      .fibb.sh.swp     swapp.sh         .viminfo

arms.sh            .bash_profile   fibo.sh            .bash_history   .kde

.sqcu.sh           .creat.c.swp

 

ls-l:

 

            "Long" format. Gives more details about the files and directories in the current directory.

 

 

 

 

 

OUTPUT:

 

[2mcaa2@mca24~]$ ls-l

 

total 32

 

-rw-r--r--          1 2mcaa2 2mcaa2 232 Jul 1 19:44 arms.sh

-rw-r--r--          1 2mcaa2 2mcaa2 197 Jul 2 19:17 fibb.sh

-rw-r--r--          1 2mcaa2 2mcaa2 233 Jul 2 19:16 fibo.sh

-rw-r--r--          1 2mcaa2 2mcaa2 124 Jul 4 16:44 revere.sh

-rw-r--r--          1 2mcaa2 2mcaa2 160 Jul 6 20:29 sqcu.sh

-rw-r--r--          1 2mcaa2 2mcaa2 157 Jul 6 19:42 sum.sh

-rw-r--r--          1 2mcaa2 2mcaa2 175 Jul 6 20:22 swapp.sh

 

 

ls-a:

 

            List "hidden" files in current directory (Those starting with a. character).

 

OUTPUT:

 

.                       arms.sh            .bash_profile   .create.c.swp   .fibb.sh.swp     .kde    

.sww.sh           swp                  ..                      .bash_history   .fibo.sh            reverse.sh .\sqcu.sh      .fork.c.swp             .zshrc               .bash.logout

 

 

ls-la:

 

            Options may usually be combined. This particular combination would list both hidden and unhidden files in the long format.

 

OUTPUT:

 

total 176

 

drwx-----         3          2mcaa2      2mcaa2      4096     Jul       6        20:29    .

drwxr-xr-x       386      root             root           12288  Jul       30      15:00    ..          

-rw------           1          2mcaa2       2mcaa2     12288  Dec     12      2008     .

-rw-r--r--          1          2mcaa2       2mcaa2     232      Jul       1        19:44    arms.sh

-rw-r--r--          1          2mcaa2       2mcaa2     197       Jul       2        19:17    fibb.sh

 

 

 

 

 

 

mv:

            The "move" command is how you rename files.

Syntax:   mv oldfilename newfilename

 

OUTPUT:

 

[2mcaa2@mca24~]$ mv swapp.sh  swap.sh

[2mcaa2@mca24~]$ ls

 

arms.sh            fibb.sh             fibo.sh             reverse.sh               swap.sh

                      

 

cp:

            Allowos you to copy one or more files.

 

syntax:      cp oldfilename.sh newfilename.sh

 

OUTPUT:

 

[2mcaa2@mca24~]$ cp fibb.sh fibonaci.sh

 

 

rm:

            Deletes a file. BE CAREFULL!! There is no "undeleted" command.

 

syntax:            rm filename.sh

 

OUTPUT:

 

[2mcaa2@mca24~]$ rm sum.sh

 

 

cat:

            Sends the contents of a file to stdout (usually the display screen). The name comes from "concatenate".

 

syntax:            cat

 

OUTPUT:

 

[2mcaa2@mca24~]$ cat

Welcome to all

Welcome to all

 

 

more:

            Like cat but display a files one page a time.

 

syntax:            more filename.sh

 

 

OUTPUT:

 

[2mcaa2@mca24~]$ more arithmetic.sh

 

echo "Read two values";

read a b;

c='expr $a + $b';

d='expr $a - $b';

e='expr $a /* $b';

f='expr $a % $b';

echo "c = $c";

echo "d = $d";

echo "e = $e";

echo "f = $f";

 

 

wc:

 

            Counts the number of lines, words and characters in a file.

 

Syntax:   wc filename.sh

 

OUTPUT:

 

[2mcaa2@mca24~]$ wc arithmetic.sh

 

10        35        163      arithmetic.sh

 

 

tail-n:

 

            Display the last n lines of a file.

 

Syntax:   tail-n lines filename.sh

 

 

 

 

 

 

OUTPUT:

 

[2mcaa2@mca24~]$ tail -2 arithmetic.sh

 

echo "e = $e";

echo "f = $f";

 

 

head-n:

 

            Display the first n lines of a file.

 

Syntax:  head -n filename.sh

 

OUTPUT:

 

[2mcaa2@mca24~]$ head -3 arithmetic.sh

 

echo "Read two values";

read a b;

c = 'expr $a + $b';

 

 

mkdir:

 

            Creates a new directory, located below the presents directory. (Use pwd first tp check where you are)

 

Syntax:    mkdir directoryname

 

OUTPUT:

 

[2mcaa2@mca24~]$ mkdir khs

 

 

rmdir:              

 

            Deletes a directory.

 

Syntax:  rmdir directoryname

 

OUTPUT:

 

[2mcaa2@mca24~]$ rmdir khs

 

man:

 

            The most important UNIX command. It displays the manual pages fir a chosen UNIX command. Press [Enter] to advance one line, [Spacebar] to advance one page, and [Q] key to quit and return to the UNIX prompt.

 

Syntax:   man mkdir

 

OUTPUT:

 

NAME                        mkdir -make directories

SYNOPSIS     mkdir [OPTION] DIRECTORY....

 

DESCRIPTION

           

            Create the DIRECTORY(ies), if they do not already exits.

            Mandatory arguments to long options are mandatory for short options too.

            -z, --context = CONTEXT (SE Linux) set security context to CONTEXT.

            -m, --mode = NODE

            set permission mode (as in chmod), not rwxrwxrwx -unmask.

 

AUTHOR

 

            Written by David Mackenzie.

 

REPORTING BUGS

           

            Report bugs to <bug-coreutils@gnu.org>.

 

man-k:

 

            Displays all UNIX commands related to a given keyword.

 

Syntax:  man command -k

 

OUTPUT:

 

[2mcaa2@mca24~]$ man mkdir -k

 

mkdir               (1)   - make directories

mkdir               (2p) - make directories

mkdir               (2)   - create a directory

mkdir               (3p) - make a directory

mkdirat                        (2)   - create a directory relative to a directory file descriptor

mkdir hier                    (1x) - makes a directory hierarchy

 

 

date:

 

            Shows the current time and date.

 

syntax:            date

 

OUTPUT:

 

[2mcaa2@mca24~]$ date

 

Wed Jul 8 20:49:48 IST 2009

 

 

logout:

 

            Terminate the current login session, land returns you to your telnet client, if that is how you established the session originally.

 

syntax:            logout

 

OUTPUT:

 

[2mcaa2@mca24~]$ logout

 

There are stopped jobs

 

[2mcaa2@mca24~]$

 

 

 

 

 

 

 

 

 

 

 

                 

 

 

         

2./* CREATE OPEN CLOSE SYSTEM CALL */

 

 

 

#include<stdio.h>

#include<stdlib.h>                           

#include<fcntl.h>                

#include<unistd.h>

#include<sys/types.h>

int main(int argc, char *argv[])

{                                                                                         

int fd1;

char buf[4096];

fd1=creat(argv[1],O_WRONLY);

if(fd1<0)

{

printf("\n error creating file %s \n",argv[1]);

exit(0);

}

close(fd1);

printf("/n fib %s is created  sucessfully", argv[1]);

}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

OUTPUT:

 

 

[2mcaa17@mca24 ~]$ vim rlab2.c

[2mcaa17@mca24 ~]$ gcc rlab2.c

[2mcaa17@mca24 ~]$ ./a.out rexample.c

 

/n fib rexample.c is created  successfully

 

[2mcaa17@mca24 ~]$./a.out rexample.c

 

error creating file rexample.c

 

[2mcaa17@mca24 ~]$ ./a.out

              

error creating file (null)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

                                     

                                  3.  /* EXEC SYSTEM CALL */

 

 

 

 

#include<unistd.h>

#include<stdio.h>

#include<sys/types.h>

#include<sys/stat.h>

#include<stdlib.h>

#include<fcntl.h>

int system(const char * cmd)

{

pid_t pid;

int status;

if(cmd==NULL)

status = 1;

else if((pid=fork())<0)

status = -1;

else if(pid==0)

{

printf("\n\n Now executing command %s \n \n",cmd );

sleep(2);

execl("/bin/sh","sh","c",cmd,(char *)0);

_exit(127);

}

return(status);

}

int main()

{

int st;

st=system("date");

st=system("uname -a");

}

 

 

 

 

 

 

 

 

 

 

                                          

OUTPUT:

                            

 

                               /* EXEC SYSTEM CALL */

 

 

[2mcaa17@mca24 ~]$ vim  rlab8.c

[2mcaa17@mca24 ~]$ gcc  rlab8.c

[2mcaa17@mca24 ~]$ ./a.out

 

 

Now executing command date

 

 

Now executing command uname -a

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

                           4.  /*LSEEK SYSTEM CALL */

 

 

 

 

#include<stdio.h>

#include<unistd.h>

#include<sys/types.h>

#include<sys/stat.h>

#include<stdlib.h>

#include<fcntl.h>

int main(int argc,char *argv[])

{

 

int lv,ret,fd,n;

char buff[4096];

fd=open(argv[1],O_RDONLY);

lv=lseek(fd,0,SEEK_END);

lseek(fd,0,SEEK_SET);

printf("LV=%d,LV/2=%d",lv,lv/2);

while((ret=read(fd,buff,4096))!=-1)

{

write(STDOUT_FILENO,buff,lv/2);

printf("\n\n");

exit(0);

}

}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

/*LSEEK SYSTEM CALL */

 

 

 

 

OUTPUT:

 

 

 

 

[2mcaa17@mca24 ~]$ vim rlab6.c

[2mcaa17@mca24 ~]$ gcc rlab6.c

[2mcaa17@mca24 ~]$ ./a.out rlab1.c

#include <sys/types.h>

#include <sys/stat.h>

#include<stdio.h>

#include<stdlib.h>

main(int argc,char *argv[])

{

int i;

struct stat statbuff;

char *ptr;

for(i=1; i<argc; i++)

{

printf ("%s",argv[i]);

if(stat(argv[i],&statbuff)<0)

printf("fstat error");

switch(statbuff.st_mode & S_IFMT)

{

case S_IFDIR: ptr="directory";

break;

case S_IFCHR: ptr="charac

 

LV=702,LV/2=351

 

 

                

 

 

 

 

 

 

 

 

 

 

                                  5. /*FILE TYPES */             

 

                   

#include <sys/types.h>

#include <sys/stat.h>

#include<stdio.h>

#include<stdlib.h>

main(int argc,char *argv[])

{

int i;

struct stat statbuff;

char *ptr;

for(i=1; i<argc; i++)

{

printf ("%s",argv[i]);

if(stat(argv[i],&statbuff)<0)

printf("fstat error");

switch(statbuff.st_mode & S_IFMT)

{

case S_IFDIR: ptr="DIRECTORY";

break;

case S_IFCHR: ptr="CHARACTER ";

break;

case S_IFBLK:  ptr="BLOCK SPECIAL";

break;

case S_IFREG:

ptr="REGULAR";

break;

#ifdef S_IFLINK

case S_IFLINK:

ptr="SYMBOLIC LINK";

break;

Wednesday, December 5, 2012

Solution: UNABLE TO READ DATA FROM THE TRANSPORT CONNECTION: NET_IO_CONNECTIONCLOSED.

Server Error in '/' Application.


Unable to read data from the transport connection: net_io_connectionclosed.


Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.IO.IOException: Unable to read data from the transport connection: net_io_connectionclosed.

Source Error: 

 

Line 73:           //  client.Credentials = aCred;

Line 74:             MailMessage message = ComposeEmailMessage(fromName, fromEmail, toAddressList, subject, emailBody, isHTML);

Line 75:             client.Send(message);

Line 76:         }

Line 77:         catch (Exception e)


Source File: c:\inetpub\vhosts\aspdotnet-rajkumar.com\httpdocs\landing\Cont.aspx.cs    Line: 75 

Stack Trace: 

 

[IOException: Unable to read data from the transport connection: net_io_connectionclosed.]

   System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer, Int32 offset, Int32 read, Boolean readLine) +1063455

   System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine) +248

   System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller) +16

   System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) +642

   System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) +159

   System.Net.Mail.SmtpClient.GetConnection() +35

   System.Net.Mail.SmtpClient.Send(MailMessage message) +1213

 

[SmtpException: Failure sending mail.]

   System.Net.Mail.SmtpClient.Send(MailMessage message) +1531

   Contactus.SendSimpleEmail(String toAddressList, String subject, String emailBody, Boolean isHTML) in c:\inetpub\vhosts\aspdotnet-rajkumar.com\httpdocs\landing\Cont.aspx.cs:75

 

[Exception: Error sending email from info@aspdotnet-rajkumar.com]

   Contactus.SendSimpleEmail(String toAddressList, String subject, String emailBody, Boolean isHTML) in c:\inetpub\vhosts\aspdotnet-rajkumar.com\httpdocs\landing\Cont.aspx.cs:79

   Contactus.Sendadminmail(String name, String email, String Mobile) in c:\inetpub\vhosts\aspdotnet-rajkumar.com\httpdocs\landing\Cont.aspx.cs:34

   Contactus.Submit_Click1(Object sender, EventArgs e) in c:\inetpub\vhosts\aspdotnet-rajkumar.com\httpdocs\landing\Cont.aspx.cs:21

   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111

   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110

   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10

   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13

   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36

   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

 


Version Information: Microsoft .NET Framework Version:2.0.50727.5448; ASP.NET Version:2.0.50727.5456

Solve: WebException , the remote name could not be resolved

Server Error in '/' Application.


The remote name could not be resolved: 'mail.aspdotnet-rajkumar.com/'

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Net.WebException: The remote name could not be resolved: 'mail.aspdotnet-rajkumar.com/'

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace: 

 

[WebException: The remote name could not be resolved: 'mail.aspdotnet-rajkumar.com/']

   System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) +5501831

   System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) +202

   System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) +21

   System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) +332

   System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) +160

   System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) +159

   System.Net.Mail.SmtpClient.GetConnection() +35

   System.Net.Mail.SmtpClient.Send(MailMessage message) +1213

 

[SmtpException: Failure sending mail.]

   System.Net.Mail.SmtpClient.Send(MailMessage message) +1531

   Contactus.SendSimpleEmail(String toAddressList, String subject, String emailBody, Boolean isHTML) +103

 

[Exception: Error sending email from admin@aspdotnet-rajkumar.com/]

   Contactus.SendSimpleEmail(String toAddressList, String subject, String emailBody, Boolean isHTML) +161

   Contactus.Sendadminmail(String name, String email, String Mobile) +222

   Contactus.Submit_Click1(Object sender, EventArgs e) +83

   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111

   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110

   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10

   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13

   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36

   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

 


Version Information: Microsoft .NET Framework Version:2.0.50727.5448; ASP.NET Version:2.0.50727.5456

How to solve this error Bad sequence of commands. The server response was: This mail server requires authentication

Server Error in '/' Application.


Bad sequence of commands. The server response was: This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Mail.SmtpException: Bad sequence of commands. The server response was: This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server.

Source Error: 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 

[SmtpException: Bad sequence of commands. The server response was: This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server.]
   System.Net.Mail.RecipientCommand.CheckResponse(SmtpStatusCode statusCode, String response) +1066623
   System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception) +241
   System.Net.Mail.SmtpClient.Send(MailMessage message) +1480
   Contactus.SendSimpleEmail(String toAddressList, String subject, String emailBody, Boolean isHTML) +103

[Exception: Error sending email from admin@aspdotnet-rajkumar.in]
   Contactus.SendSimpleEmail(String toAddressList, String subject, String emailBody, Boolean isHTML) +161
   Contactus.Sendadminmail(String name, String email, String Mobile) +222
   Contactus.Submit_Click1(Object sender, EventArgs e) +83
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565



Version Information: Microsoft .NET Framework Version:2.0.50727.5448; ASP.NET Version:2.0.50727.5456