#!/usr/bin/perl# Simple DHCP client - send a LeaseQuery (by IP) and receive the responseuse IO::Socket::INET;use Net::DHCP::Packet;use Net::DHCP::Constants;$usage = "usage: $0 DHCP_SERVER_IP DHCP_CLIENT_IP\n"; $ARGV[1] || die $usage;# create a socket$handle = IO::Socket::INET->new(Proto => 'udp',Broadcast => 1,PeerPort => '67',LocalPort => '67',PeerAddr => $ARGV[0])or die "socket: $@"; # yes, it uses $@ here# create DHCP Packet$inform = Net::DHCP::Packet->new(op => BOOTREQUEST(),Htype => '0',Hlen => '0',Ciaddr => $ARGV[1],Giaddr => $handle->sockhost(),Xid => int(rand(0xFFFFFFFF)), # random xidDHO_DHCP_MESSAGE_TYPE() => DHCPLEASEQUERY);# send request$handle->send($inform->serialize()) or die "Error sending LeaseQuery: $!\n";#receive response$handle->recv($newmsg, 1024) or die;$packet = Net::DHCP::Packet->new($newmsg);print $packet->toString();
MSSQL server
#!/usr/bin/perl use DBI; my $DSN = 'driver={SQL Server};Server=localhost; database=AdventureWorks;TrustedConnection=Yes'; my $dbh = DBI->connect("dbi:ODBC:$DSN") or die "$DBI::errstr\n"; my $sth = $dbh->prepare('select top 10 * from Sales.vSalesPerson') or die "Couldn't prepare statement: " . $dbh->errstr; $sth->execute(); while( @data = $sth->fetchrow_array()) { foreach(@data) { print "[$_]"; } print "\n\n"; } $sth->finish; $dbh->disconnect;
Thursday, May 23, 2013
POST FORM
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment