#!/usr/bin/perl use strict; use IO::Socket; use DBI; use DBD::Oracle; our (@command, $command); our ($socket_success_fl); our $svcpk; my $cable_command; ##$cable_command = ' ## ## ## 8002721493 ## 01 ## 19 Bow Circle ## Bow Circle Business Ctr Unit 402 ## Hilton Head Island ## SC ## 29926 ## ##'; ####$cable_command = $ARGV[0] #### or die "Could not find an argument \n"; print "$cable_command\n"; $socket_success_fl = 'N'; socket_connect(); if ($socket_success_fl =~ /Y/){ process_command(); socket_close(); }elsif ($socket_success_fl =~ /N/){ print "Unable to connect to socket!!....\n"; } sub socket_connect { socket (SH, PF_INET, SOCK_STREAM, getprotobyname('tcp')) || die $!; my $dest = sockaddr_in (22928, inet_aton('172.17.15.102')); connect (SH, $dest) || die $!; $socket_success_fl = 'Y'; print "Connected to socket\n"; } sub process_command { my $v_param; my $buffer; $v_param = $cable_command; @command = split(/&/,$v_param); foreach $command (@command) { print "$command\n"; if ($command =~ /SVCPK=/ ) { $svcpk = substr($command,6,10); print "svcpk = ", $svcpk, " \n"; } else { print "About to send command\n"; send (SH, "$command\r", 0); print "sent command\n"; print "about to read response buffer\n"; sysread (SH, $buffer, 1000); print "read response buffer\n"; print "response = ", $buffer, " \n"; } } } sub socket_close{ close(SH); print "Socket closed \n";