Break Connections

Hi,
i want to break texture and shader connections through MEL,
but the problem with layeredShaders and normal Shaders(blinn,lambert etc...)
How to make the condition here to break both the shaders at a time.
This is my script now it breaks LayeredShaders,but problem with normal shader nodes.

global proc breakTexConnections()
{
string $selList[] = ls -mat;
string $selTex[] = ls -tex;
string $lShader[] = ls -typ "layeredShader";
for( $i=0; $i<size( $selList ); $i++ )
{
catch(connectionInfo -id ($lShader[$i] +".inputs[0]" + ".color" ));
string $breakInfo = connectionInfo -sourceFromDestination ( $lShader[$i] +".inputs[0]" + ".color" );
catch ( disconnectAttr $breakInfo ( $lShader[$i] +".inputs[0]" + ".color" ) );
setAttr ($lShader[$i] +".inputs[0]" + ".color") -type double3 1 1 1 ;
}
if( connectionInfo -id ( $selList[$i] + ".color" ) )
{
string $breakInfo = connectionInfo -sourceFromDestination ( $selList[$i] + ".color" );
catch ( disconnectAttr $breakInfo ( $selList[$i]+".color" ) );
setAttr ($selList[$i]+".color") -type double3 1 1 1;
setAttr "layeredShader1.inputs[0].color" -type double3 1 1 1 ;
}
}

Thanks.

You shoudl actually do it differently. you should ask all shading groups in existence then list all their connections and disconnect them.

Not sure what your exactly after but thsi should do the trick:

CODE
for ($item in listHistory("-f",0,"-ag",1,ls -et shadingEngine)){
  $list=getEverySecond2(listConnections -c 1 -p 1 -s 0 -d 1 $item);
  for($i=0;$i<size($list);$i+=1){
    if (match "[.]color$" $list[$i+1]!=""){
      print ("disconnected: "+connectionInfo -sfd $list[$i+1]+" "+$list[$i+1]);
      disconnectAttr  connectionInfo -sfd $list[$i+1] $list[$i+1];
    }
  }

}

CODE
global proc breakTexConnections()
{
    string $selTex[] = ls -tex;
    for($each in ls -mat)
    {
    if(nodeType $each == "layeredShader")
        {
        string $LSconns[] = listConnections -c 1 -s 1 -d 0 $each;
               for($LScon in $LSconns)
            {
            string $buffer[];
            tokenize ($LScon, ".", $buffer);
            if(gmatch $buffer[1] "inputs*")
                {
                string $theSource = connectionInfo -sourceFromDestination $LScon;
                disconnectAttr $theSource $LScon;
                string $theNode = $buffer[0];
                string $theAttr = $buffer[1];
                setAttr ($theNode + "." + $theAttr + ".color") -type double3 1 1 1;
                }
            }
        }
    string $conns[] = listConnections -p 1 -s 1 -d 0 $each;
    for ($conn in $conns)
        {
        string $buffer02[];
        tokenize($conn, ".", $buffer02);
        string $nodeName = $buffer02[0];
        string $nodeType[] = nodeType -i $nodeName;
        if($nodeType[0] == "texture2d" || $nodeType[0] == "texture3d")
            {
            string $theDestination[] = connectionInfo -destinationFromSource $conn;
                      disconnectAttr $conn $theDestination[0];
            }
        }
    }
}

I know little bit long but It works for me. Hope it helps.

CODE
source channelBoxCommand.mel;
for($i in ls -mat){
    if(nodeType $i != "layeredShader"){
    CBdeleteConnection($i+".color");
    CBdeleteConnection($i+".transparency");
    CBdeleteConnection($i+".incandescence");
    if(nodeType $i != "particleCloud")
    CBdeleteConnection($i+".ambientColor");
   }
}

QUOTE
I know little bit long but It works for me. Hope it helps.

Yah, its working but, the problem with shader to render node shader connections.like blinn.outColor and Phonge.color.There is no connection then i want that material 1 1 1. My file has various connections.and also
where we can find "channelBoxCommand.mel" ?