Friday, June 26, 2009

search for a file in UNIX

find . -name "*.gz" –print

gunzip files in a directory containing sub directory in unix

find . -type f -name "*.gz" -exec gunzip {} \;

 

Monday, June 15, 2009

ADO.NET : Calling Store procedure

ADO.NET : Calling Store procedure

private void SpTest (id, string name)

{

SqlConnection sqlConn= new SqlConnection(_sqlConnString);

try

{

SqlCommand sqlCmd = new SqlCommand();

sqlCmd.CommandText = "sp_test";

sqlCmd.CommandType = CommandType.StoredProcedure;

sqlCmd.Parameters.Add("id", SqlDbType.Int);

sqlCmd.Parameters.Add("name", SqlDbType.VarChar);

sqlCmd.Parameters[0].Value = id;

sqlCmd.Parameters[0].Direction = ParameterDirection.Input;

sqlCmd.Parameters[1].Value = name;

sqlCmd.Parameters[0].Direction = ParameterDirection.Input;

sqlCmd.Connection = sqlConn;

sqlConn.Open();

sqlCmd.ExecuteNonQuery();

}

catch (Exception exSp)

{

throw exSp;

}

finally

{

sqlConn.Close();

}

}

Wednesday, June 10, 2009

ls –lR Unix Command in sFtp C# DotNet


This code functionality facilitates the ls -lR command in C# project and is for the project which is using Tamis.SharpSsh 3rd party dll to Unix data transmission. 

ls -lR  functionality not provided by them. So I came across the need of it and wrote as below .



Download 3rd party .dll for SFTP data transmission.


 public Tamir.SharpSsh.java.util.Vector lsLr(string path)   
  {   
       Tamir.SharpSsh.java.util.Vector putLsEntry = new Tamir.SharpSsh.java.util.Vector();   
       Tamir.SharpSsh.java.util.Vector getLsEntry = new Tamir.SharpSsh.java.util.Vector();   
       Tamir.SharpSsh.java.util.Vector recLsEntry = new Tamir.SharpSsh.java.util.Vector();   
       Tamir.SharpSsh.jsch.ChannelSftp.LsEntry lsEntry;   
       getLsEntry = _sftp.ls(path);   
       int i = 0;   
       for (i = 0; i < getLsEntry.Count; i++)   
       {   
            lsEntry = (Tamir.SharpSsh.jsch.ChannelSftp.LsEntry)getLsEntry[i];   
            if (lsEntry.getFilename().ToString().Trim() == "." || lsEntry.getFilename().ToString().Trim() == "..") { continue; };   
            if (lsEntry.getAttrs().getPermissionsString().StartsWith("d"))   
            {   
                recLsEntry = lsLr(path + "/" + lsEntry.getFilename());   
                int j = 0;   
                 for (j = 0; j < recLsEntry.Count; j++)   
                 {   
                     putLsEntry.add(recLsEntry[j]);   
                 }   
            }   
            else   
            {   
                putLsEntry.add(lsEntry);   
            }   
       }   
       return putLsEntry;   
 }   

Tuesday, June 9, 2009

Problem in running Iptables from CGI ?

Problem in running Iptables commands from CGI ?

 

This is because ,  CGI not having root privileges  even though you are login as root or Admin.

 

To run root privileges commands through CGI .

 

Step:

 

If you run sudo it will not support.So alter sudoers file and restarted apache.

 

 

Ucase in DataTable.Select(

Ucase in DataTable.Select(

If you want to apply a filter condition on base of upper cases like what we do in sql server as ucase(columnname)=<UPPERCASE VALUE> .

In ADO.NET - Just make it
 datatable.CaseSensitive = false;  

syntax:

 dtCopy.CaseSensitive = false;  
 DataRow[] drFilter = dtCopy.Select("Source_Dir=’/LOCAL/HOME’”);  
 dtCopy.CaseSensitive = true;  

Tuesday, June 2, 2009

XAMPP - Make your Computer a Webserver: Apache, PHP, MySQL

XAMPP - Make your Computer a Webserver: Apache, PHP, MySQL



XAMPP is a free installer that has Apache / PHP / MYsql / perl and more integrated so you won't have to configure anything yourself. HTML / CSS Tutorial.

Code Formater

Paste Here Your Source Code
Source Code Formatting Options
1) Convert Tab into Space :
2) Need Line Code Numbering :
3) Remove blank lines :
4) Embeded styles / Stylesheet :
5) Code Block Width :
6) Code Block Height :
7) Alternative Background :
Copy Formatted Source Code
 
Preview Of Formatted Code