I need to run a pearl script.

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Author Message
Seph
DD-WRT Novice


Joined: 26 Oct 2008
Posts: 15

PostPosted: Wed Dec 10, 2008 18:52    Post subject: I need to run a pearl script. Reply with quote
I need to run a script, but I have no idea how. I got it unto my router using wget, and have installed pearl and OpenVPN, now I just need to run the script.
Code:
#!/usr/bin/perl
use strict;

# torrentfreedom perl client
# v1.1

# initiates and manages a connection to TorrentFreedom without using a GUI.

# set additional proxy settings here - check out openvpn.net's manpage for options.
# eg: my $additional_options = "--http-proxy 11.22.33.44 8080";
# to tell the client to use a http proxy.
my $additional_options = "";

my $username = shift;
my $password = shift;

if (length($username) < 1 || length($password) < 1)
{
   # poke user if they didn't enter a username or password
   print "usage: perl torrentfreedom.pl [username] [password]\n";
   exit;
}

# report version - used for stats and update notifications
my $argstream1 = "https://www.torrentfreedom.com/scripts/version.php?username=$username&password=$password";
my $argstream2 = "--output-document=/dev/null";
system("wget",$argstream1,$argstream2);

# get config file
$argstream1 = "https://www.torrentfreedom.com/scripts/config.php?username=$username&password=$password";
$argstream2 = "--output-document=$username.conf";
system("wget",$argstream1,$argstream2);

# get CA
$argstream1 = "https://www.torrentfreedom.com/scripts/ca.php?username=$username&password=$password";
$argstream2 = "--output-document=ca.crt";
system("wget",$argstream1,$argstream2);

# get user's cert
$argstream1 = "https://www.torrentfreedom.com/scripts/usercrt.php?username=$username&password=$password";
$argstream2 = "--output-document=$username.crt";
system("wget",$argstream1,$argstream2);

# get user's key
$argstream1 = "https://www.torrentfreedom.com/scripts/userkey.php?username=$username&password=$password";
$argstream2 = "--output-document=$username.key";
system("wget",$argstream1,$argstream2);

# connect to openvpn - note, we never return from this - so the perl script basically ends here.
exec("openvpn --config $username.conf $additional_options") or print STDERR "couldn't run openvpn: $!";

# that's it.
Sponsor
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Wed Dec 10, 2008 21:07    Post subject: Reply with quote
Change:
Code:
 #!/usr/bin/perl

to:
Code:
#!/opt/bin/perl

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
Seph
DD-WRT Novice


Joined: 26 Oct 2008
Posts: 15

PostPosted: Wed Dec 10, 2008 21:38    Post subject: Reply with quote
I changed the line I tried to run the script, but it returns "-sh: /proxy.pl/: not found"

"ls" tells me that it is there, though. What's wrong?

Code:
root@DD-WRT:~# wget http://rapidshare.com/files/172192543/proxy.pl
Connecting to rapidshare.com (195.122.131.22:80)
root@DD-WRT:~# ls
proxy.pl
root@DD-WRT:~# proxy.pl
-sh: proxy.pl: not found
root@DD-WRT:~# /proxy.pl
-sh: /proxy.pl: not found
root@DD-WRT:~# /proxy.pl/
-sh: /proxy.pl/: not found
root@DD-WRT:~#
Seph
DD-WRT Novice


Joined: 26 Oct 2008
Posts: 15

PostPosted: Thu Dec 11, 2008 15:46    Post subject: Reply with quote
Bump.
soulstace
DD-WRT Guru


Joined: 04 Aug 2007
Posts: 6427

PostPosted: Thu Dec 11, 2008 15:53    Post subject: Reply with quote
maybe you need to make it executable

chmod +x proxy.pl
./proxy.pl
Seph
DD-WRT Novice


Joined: 26 Oct 2008
Posts: 15

PostPosted: Thu Dec 11, 2008 19:03    Post subject: Reply with quote
Thank you, it worked. I am now able to run the script, but after I do, I lose my internet connection. I'm still able to talk to the router, so it hasn't crashed, it just can't acces the web through the proxy. Here's my output:

Code:
root@DD-WRT:/opt/proxy# ./torrentfreedom.pl username password
Thu Dec 11 19:54:46 2008 OpenVPN 2.1_rc7 mipsel-unknown-linux-gnu [SSL] [LZO1] [EPOLL] built on Jul 27 2008
Enter Auth Username:username
Enter Auth Password:
Thu Dec 11 19:54:56 2008 WARNING: file 'username.key' is group or others accessible
Thu Dec 11 19:54:56 2008 LZO compression initialized
Thu Dec 11 19:54:56 2008 Control Channel MTU parms [ L:1544 D:140 EF:40 EB:0 ET:0 EL:0 ]
Thu Dec 11 19:54:56 2008 Data Channel MTU parms [ L:1544 D:1450 EF:44 EB:135 ET:0 EL:0 AF:3/1 ]
Thu Dec 11 19:54:56 2008 Attempting to establish TCP connection with 81.173.31.83:443 [nonblock]
Thu Dec 11 19:54:57 2008 TCP connection established with 81.173.31.83:443
Thu Dec 11 19:54:57 2008 Socket Buffers: R=[43689->65534] S=[16384->65534]
Thu Dec 11 19:54:57 2008 TCPv4_CLIENT link local: [undef]
Thu Dec 11 19:54:57 2008 TCPv4_CLIENT link remote: 81.173.31.83:443
Thu Dec 11 19:54:57 2008 TLS: Initial packet from 81.173.31.83:443, sid=39c35fd7 89140fd3
Thu Dec 11 19:54:58 2008 VERIFY OK: depth=1, /C=../ST=../L=./O=../CN=.._CA/emailAddress=..
Thu Dec 11 19:54:58 2008 VERIFY OK: nsCertType=SERVER
Thu Dec 11 19:54:58 2008 VERIFY OK: depth=0, /C=../ST=../L=./O=../CN=boris/emailAddress=..
Thu Dec 11 19:55:03 2008 Data Channel Encrypt: Cipher 'BF-CBC' initialized with 128 bitkey
Thu Dec 11 19:55:03 2008 Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Thu Dec 11 19:55:03 2008 Data Channel Decrypt: Cipher 'BF-CBC' initialized with 128 bitkey
Thu Dec 11 19:55:03 2008 Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Thu Dec 11 19:55:03 2008 Control Channel: TLSv1, cipher TLSv1/SSLv3 DHE-RSA-AES256-SHA,2048 bit RSA
Thu Dec 11 19:55:03 2008 [boris] Peer Connection Initiated with 81.173.31.83:443
Thu Dec 11 19:55:04 2008 SENT CONTROL [boris]: 'PUSH_REQUEST' (status=1)
Thu Dec 11 19:55:04 2008 PUSH: Received control message: 'PUSH_REPLY,route-gateway 81.173.5.129,redirect-gateway def1,dhcp-option DNS 208.67.222.222,dhcp-option DOMAIN boris.baneki.org,topology subnet,ping 10,ping-restart 40,ifconfig 81.173.5.192 255.255.255.128'
Thu Dec 11 19:55:04 2008 OPTIONS IMPORT: timers and/or timeouts modified
Thu Dec 11 19:55:04 2008 OPTIONS IMPORT: --ifconfig/up options modified
Thu Dec 11 19:55:04 2008 OPTIONS IMPORT: route options modified
Thu Dec 11 19:55:04 2008 OPTIONS IMPORT: route-related options modified
Thu Dec 11 19:55:04 2008 OPTIONS IMPORT: --ip-win32 and/or --dhcp-option options modified
Thu Dec 11 19:55:04 2008 TUN/TAP device tun0 opened
Thu Dec 11 19:55:04 2008 TUN/TAP TX queue length set to 100
Thu Dec 11 19:55:04 2008 /sbin/ifconfig tun0 81.173.5.192 netmask 255.255.255.128 mtu 1500 broadcast 81.173.5.255
Thu Dec 11 19:55:04 2008 /sbin/route add -net 81.173.31.83 netmask 255.255.255.255 gw 83.91.98.1
Thu Dec 11 19:55:04 2008 /sbin/route add -net 0.0.0.0 netmask 128.0.0.0 gw 81.173.5.129
Thu Dec 11 19:55:04 2008 /sbin/route add -net 128.0.0.0 netmask 128.0.0.0 gw 81.173.5.129
Thu Dec 11 19:55:04 2008 Initialization Sequence Completed

Works just fine when I run it from my Ubuntu-box.
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum