I have installed perl in windows 7 and configured the proxy (http & ftp) as at How do I install a module? Strawberry Perl issues by Axeman, replacing proxy with my lan proxy IP and port respectively. However, when I run cpanm App::cpanminus, it returns a message for proxy authentication which has faile. Its requesting for a username.
you need to set the http_proxy environment variable in the form:
http_proxy=http://user:password#host:port/
Otherwise just use the cpan client.
Edit: 2012-08-29
If you do not have the proxy username and password, you are not getting out through that proxy regardless of the client software.
Related
I'm working with CPANM to interact with a proxy that requires username and password. I specified the settings when running "o conf init /proxy/ under cpan". My perception is the variables used in a unix environment for specifying proxies are not standard throughout the environment. Other unix utilities are working correctly through the proxy after setting environment variables to the correct values.
My questions are the following:
How does CPANM interfaces with any environment variables? What would they be?
Is there a relevant area of the code we can look to help remove ambiguity, I'm thinking there is an LWP interface inside of CPANM?
https://github.com/miyagawa/cpanminus/blob/devel/App-cpanminus/cpanm
####:/mnt/c/Projects$ sudo cpanm install Catalyst::Helper -v
cpanm (App::cpanminus) 1.7040 on perl 5.022001 built for x86_64-linux-gnu-thread-multi
Work directory is /home/####/.cpanm/work/1543605706.124
You have make /usr/bin/make
You have LWP 6.36
You have /bin/tar: tar (GNU tar) 1.28
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by John Gilmore and Jay Fenlason.
Searching install () on cpanmetadb ...
########:/mnt/c/Projects$ env | grep HTTP_proxy
HTTP_proxy=http://####:###
As far as I can see, cpanm (actually App::Cpanminus relies on HTTP::Tiny to run HTTP requests.
From the docs of HTTP::Tiny :
HTTP::Tiny can proxy both http and https requests. Only Basic proxy authorization is supported and it must be provided as part of the proxy URL: http://user:pass#proxy.example.com/.
HTTP::Tiny supports the following proxy environment variables: http_proxy or HTTP_PROXY, https_proxy or HTTPS_PROXY, all_proxy or ALL_PROXY
Hence you should try and specify the proxy username and password as part of the url, like :
$ export HTTP_PROXY=http://<user>:<password>#<url>:<port>
$ export HTTPS_PROXY=http://<user>:<password>#<url>:<port>
Also, as per documentation, the HTTP_PROXY setting is accepted by LWP::UserAgent (the primary HTTP client used by the cpan command line utility), while HTTPS_PROXY is supported by curl (fallback of cpan when LWP fails). See the LWP::UserAgent docs and the curl docs.
Hence HTTP_PROXY/HTTPS_PROXY should be the common environment variables that are supported by all CPAN clients.
i need to run cpan trough proxy but when i try to configure i got errors and cant enter to cpan for the first time
root#srv-linux01:~# cpan
CPAN.pm requires configuration, but most of it can be done automatically.
If you answer 'no' below, you will enter an interactive dialog for each
configuration option instead.
Would you like to configure as much as possible automatically? [yes] no
On proxy settings:
If you're accessing the net via proxies, you can specify them in the
CPAN configuration or via environment variables. The variable in
the $CPAN::Config takes precedence.
<ftp_proxy>
Your ftp_proxy? [] http://username:password#proxyIP:Port/ <---- is ok the information?
<http_proxy>
Your http_proxy? [] http://username:password#proxyIP:Port/ <---- is ok the information?
<no_proxy>
Your no_proxy? []
If your proxy is an authenticating proxy, you can store your username
permanently. If you do not want that, just press ENTER. You will then
be asked for your username in every future session.
Your proxy user id? [] <---- username is needed again?
Your password for the authenticating proxy can also be stored
permanently on disk. If this violates your security policy, just press
ENTER. You will then be asked for the password in every future
session.
Your proxy password?
And before that i get this.
Fetching with HTTP::Tiny:
http://www.perl.org/CPAN/MIRRORED.BY.gz
Error downloading with HTTP::Tiny: Not a CODE reference at /usr/share/perl/5.18/CPAN/HTTP/Client.pm line 112, <STDIN> line 65.
Im using Ubuntu Server 14.04 LTS and Perl 5.18.2
Thanks
Yeah, this is pretty exasperating.
This SO answer suggests that maybe installing LWP (and its 18 dependencies) makes the problem better. Gosh, I'm glad I didn't have to resort to that.
The issue I had with this was that I already had http_proxy, https_proxy, and the uppercase versions of both of those set (and exported) in my environment. Just about every other program (including wget and curl) is works fine when these environment variables are present. It made no sense to have to set these again, and then still have CPAN fail, when it's obviously calling out to wget!
What did finally work for me was to follow the instructions here, setting the CPAN http_proxy config setting to the empty string. (I also had previously removed the proxy username and password settings by hand-editing ~/.cpan/CPAN/MyConfig.pm.)
$ cpan # or perl -MCPAN -e shell
cpan[1]> o conf http_proxy ""
cpan[2]> o conf ftp_proxy ""
cpan[3]> o conf proxy_user ""
cpan[4]> o conf proxy_pass ""
cpan[5]> o conf commit
cpan[6]> q
$ # I have a shell function that does basically this
$ export http_proxy="http://user:pass#proxyserver:8080"
$ for v in HTTP_PROXY https_proxy HTTPS_PROXY ftp_proxy FTP_PROXY; do
> export $v="$http_proxy"
> done
$ cpan i Devel::Repl # or whatever
Then, presumably, wget was just using the environment variables defined before calling cpan, which of course works fine. If you have a proxy that requires authentication, this article on the Arch wiki has a little script that will prompt you for the credentials, and then set all the appropriate *_proxy and *_PROXY environment variables.
On that note, just as a public service announcement, please don't put important passwords in plain-text configuration files or in your ~/.bashrc.
what I did to overcome cpan proxy behavour is to prefix the command with proxychains command.
Details about proxychains: https://github.com/haad/proxychains
My knowledge of perl is limited to running commands. I have managed to come up with a shell script to output the gav of a pom.xml, using xpath as follows:
xpath pom.xml '//project/artifactId/text()'
On a new machine right now, this does not work because I do not have the XPath.pm installed:
Can't locate XML/XPath.pm in #INC (#INC contains: /usr/lib/perl5/site_perl/5.14/x86_64-cygwin-threads /usr/lib/perl5/site_perl/5.14 /usr/lib/perl5/vendor_perl/5.14/x86_64-cygwin-threads /usr/lib/perl5/vendor_perl/5.14 /usr/lib/perl5/5.14/x86_64-cygwin-threads /usr/lib/perl5/5.14 .)
I seem to remember installing XPath using cpan so I tried the following command, blindly:
cpan XPath
This is probably not the correct command to use, but I think that is unrelated to the issue I am facing. The command gives following error:
Going to read '/home/****/.cpan/Metadata'
Database was generated on Mon, 25 Aug 2014 00:41:02 GMT
Fetching with HTTP::Tiny:
http://www.perl.org/CPAN/authors/01mailrc.txt.gz
HTTP::Tiny failed with an internal error: Could not connect to 'proxy:8080': IO::Socket::INET: Bad hostname 'proxy' at /usr/lib/perl5/5.14/HTTP/Tiny.pm line 139
Proxy authentication needed!
(Note: to permanently configure username and password run
o conf proxy_user your_username
o conf proxy_pass your_password
)
Username: C-c C-c
Why is HTTP::Tiny looking for host proxy? We do have a corporate proxy with hostname proxy but that is needed only when I am on corporate network or VPN, neither of which is case right now.
How do I convince HTTP::Tiny to connect directly to internet? I do not have an envvar named http_proxy or HTTP_PROXY set.
While the environment variable is used, cpan first checks its configuration.
To view: o conf http_proxy
To clear: o conf http_proxy ''
Don't forget to use o conf commit to make the change permanent.
CPAN uses HTTP:Tiny to download info about the module you are asking for. It is lightweight so it runs fast.
Either CPAN has not been configured, or the cpan found on your path is configured to use the proxy. Determine the location of the CPAN program you are executing and proceed from there.
This msg Can't locate XML/XPath.pm in #INC (#INC contains: /usr/lib/perl5/site_perl/5.14/x86_64-cygwin-threads /usr/lib/perl5/site_perl/5.14 /usr/lib/perl5/vendor_perl/5.14/x86_64-cygwin-threads /usr/lib/perl5/vendor_perl/5.14 /usr/lib/perl5/5.14/x86_64-cygwin-threads /usr/lib/perl5/5.14 .) shows that module is not installed.
If you are on windows and using a proxy setting. You can use these commands to install module from ppm or cpan. Open a command prompt and run these commands :
set http_proxy=http://xxx.xxx.xxx.x:yyyy (xxx is your system proxy and yyyy is port)
set http_proxy_user=username (login username)
set http_proxy_pass=password (login password)
To install a module from cpan type:
cpan install modulename
The error occurs because you have set http_proxy variable to direct IP, Instead, put http_proxy=http://ipaddress , then it will work
I want to write a perl-script that loads content from internet-websites through the TOR network. The script should run on a non-gui ubuntu server (Ubuntu 12.04).
Just to make it clear: I want to install no TOR server and no TOR browser. I want to install a TOR client that makes it possible for other programs like perl scripts to access web content through the TOR network.
My questions:
Where do I find a TOR client for a non-gui ubuntu-machine?
How to install this client?
Must I install anything else (maybe some additional cpan modules)?
Do you have a short example perl script that loads a website through the TOR network?
sudo apt-get install tor - then you can either use proxychains <your command> OR usewithtor <your command> OR torify <your command>
I need to connect machines from Perl script via SSH1 and SSH2.
i am not able to find any package which works for both SSH1 and SSH2.
The following packages i have tried:
Net::SSH::Perl --- Works for SSH1 but not for SSH2.
Net::OpenSSH --- Works for SSH2 but not for SSH1.
Net::SSH2 --- Works for SSH2 but not for SSH1.
Please help me!!!
Net::SSH::Any can use Net::SSH2 or Net::OpenSSH and the development version from GitHub provides the SSH_Cmd back-end that can be used to connect to hosts supporting only version 1 of the SSH protocol.
The SSH_Cmd backend uses the system ssh binary.