All pastes #332990 Raw Edit

Untitled

public php v1 · immutable
#332990 ·published 2007-01-30 16:13 UTC
rendered paste body
<?php// Set non-device specific options$community = 'private';$tftpDest = '172.16.22.40';// Build SNMP strings$snmpCmd = '.1.3.6.1.4.1.9.2.1.55.'.$tftpDest;//read in switch IP/hostnamesini_set("auto_detect_line_endings", 1);$current_row = 1;$handle = fopen("switches.csv", "r");while ( ($data = fgetcsv($handle, 10000, ",") ) !== FALSE ){	$number_of_fields = count($data);	if ($current_row == 1)	{	//Header line	for ($c=0; $c < $number_of_fields; $c++)		{			$header_array[$c] = $data[$c];		}	}	else	{	//Data line		for ($c=0; $c < $number_of_fields; $c++)		{			$data_array[$header_array[$c]] = $data[$c];		}				// Check directory exists in TFTP root directory		@mkdir("//acs.wortech.ac.uk/l$/tftp/tftproot/".$data_array["hostname"]);		//Build remainder of SNMP options		$snmpOpt = $data_array["hostname"].'/'.date("Ymd-His").'.config enterprises.9.2.1.55.'.$tftpDest.' = "router-config"';		// Now do SNMP request		$result = snmpset($data_array["ip"], $community, $snmpCmd, 's', $snmpOpt);		// Report any errors		if ($result = false) 		{			echo "Problem with: ".$data_array["hostname"]."\n";		}		else {			echo "Success: ".$data_array["hostname"]."\n";		}	}	$current_row++;}// Close filefclose($handle);?>