| | |
is this perl doable in shell?
![]() |
•
•
Join Date: Jun 2009
Posts: 2
Reputation:
Solved Threads: 0
Shell Scripting Syntax (Toggle Plain Text)
$dgs = new IO::Socket::INET(LocalPort => $lisport, Proto => 'udp') or die "Socket: $!\n";
I have a perl script that I want to run on tomato firmware router using the current shell scripting that it supports
How would I do the above in shell? In perl you have to use IO:Socket.
Last edited by scotddn1; Jun 15th, 2009 at 10:31 pm.
Is your next question going to be
"How do I do x in shell"
where x is some perl statement involving the USE of $dgs ?
There must be a reason for opening the port, which means there's going to be more things to do with that variable once you've initialised it.
Fixing it one line at a time won't solve your problem.
"How do I do x in shell"
where x is some perl statement involving the USE of $dgs ?
There must be a reason for opening the port, which means there's going to be more things to do with that variable once you've initialised it.
Fixing it one line at a time won't solve your problem.
•
•
Join Date: Aug 2007
Posts: 165
Reputation:
Solved Threads: 18
•
•
•
•
Shell Scripting Syntax (Toggle Plain Text)
$dgs = new IO::Socket::INET(LocalPort => $lisport, Proto => 'udp') or die "Socket: $!\n";
I have a perl script that I want to run on tomato firmware router using the current shell scripting that it supports
How would I do the above in shell? In perl you have to use IOocket.
•
•
Join Date: Jun 2009
Posts: 2
Reputation:
Solved Threads: 0
This the perl code I wish do convert to shell (ash so it works on Tomato),
Shell Scripting Syntax (Toggle Plain Text)
#!/usr/bin/perl -w use IO::Socket; $ataip = '192.168.1.158'; $ataport = 5060; $server = 'voipserver'; $lport = 5070; # port to listen on $dgs = new IO::Socket::INET(LocalPort => $lport, Proto => 'udp') or die "Socket: $!\n"; while (1) { $rcv = $dgs->recv($ibuf, 2000, 0); next unless $rcv && length($rcv) >= 8; # ignore errors $raddr = inet_ntoa((sockaddr_in($rcv))[1]); # get source addr if ($raddr eq $ataip) { # packet from ATA $ibuf =~ s/(nonce=\"\w+_\w+)_[\w\-]+/$1/; # send original nonce to server $dpaddr = sockaddr_in(5070, inet_aton($server)); $dgs->send($ibuf, 0, $dpaddr); # send to server } elsif ($raddr eq $server) { # packet from server if (($nonce) = $ibuf =~ /nonce=\"(\w+)/) { # need to fix nonce ($callid) = $ibuf =~ /Call-ID: ([\w\-]+)/ or die; $enonce = '_'; # compute extended nonce $enonce .= substr($callid, hex(substr($nonce, $_, 1)), 1) for (0..7); $ibuf =~ s/(nonce=\"\w+)/$1$enonce/; # pass new nonce to ATA } $dpaddr = sockaddr_in($ataport, inet_aton($ataip)); $dgs->send($ibuf, 0, $dpaddr); # send to ATA } }
I take the reference in your first post is for this?
http://www.polarcloud.com/tomato
First, do you have a complete bash, or is that a cut-down version as well?
The answer (maybe) to the first step of opening a connection is perhaps here:
http://www.linuxquestions.org/questi...script-380706/
For more clues, more links
http://www.gnulamp.com/bashprogramming.html
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://tldp.org/LDP/abs/html/index.html
http://www.polarcloud.com/tomato
First, do you have a complete bash, or is that a cut-down version as well?
The answer (maybe) to the first step of opening a connection is perhaps here:
http://www.linuxquestions.org/questi...script-380706/
For more clues, more links
http://www.gnulamp.com/bashprogramming.html
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://tldp.org/LDP/abs/html/index.html
![]() |
Similar Threads
- perl assignment question (Perl)
- self killing perl prog (Perl)
- Wat is shell? (Shell Scripting)
- How to execute shell command form Java servlet? (Java)
- How to invoke a perl program from a perl program. (Perl)
- Advantage of using shell(ksh/bash etc) compared to perl? (Perl)
- Senior Perl Technical resource (Software Development Job Offers)
Other Threads in the Shell Scripting Forum
- Previous Thread: *nix shell script symbols
- Next Thread: getopts
| Thread Tools | Search this Thread |







ocket.