[31052] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 2297 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 25 21:09:48 2009

Date: Wed, 25 Mar 2009 18:09:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 25 Mar 2009     Volume: 11 Number: 2297

Today's topics:
    Re: How to use a variable as regular expression? <tzz@lifelogs.com>
    Re: Invoking an SSH client by clicking a URL Link <ben@morrow.me.uk>
    Re: Invoking an SSH client by clicking a URL Link cyrusgreats@gmail.com
    Re: Invoking an SSH client by clicking a URL Link (Jens Thoms Toerring)
    Re: Invoking an SSH client by clicking a URL Link <smallpond@juno.com>
    Re: Invoking an SSH client by clicking a URL Link cyrusgreats@gmail.com
    Re: Invoking an SSH client by clicking a URL Link (Jens Thoms Toerring)
    Re: Invoking an SSH client by clicking a URL Link <tadmc@seesig.invalid>
    Re: Invoking an SSH client by clicking a URL Link cyrusgreats@gmail.com
    Re: Invoking an SSH client by clicking a URL Link (Jens Thoms Toerring)
    Re: Invoking an SSH client by clicking a URL Link <ben@morrow.me.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 25 Mar 2009 15:50:55 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: How to use a variable as regular expression?
Message-Id: <86ab79gwcw.fsf@lifelogs.com>

On Tue, 24 Mar 2009 15:25:20 -0500 Tad J McClellan <tadmc@seesig.invalid> wrote: 

TJM> Ted Zlatanov <tzz@lifelogs.com> wrote:
>> On Mon, 23 Mar 2009 08:35:42 -0700 (PDT) SamL <slsamliu@gmail.com> wrote: 
>> 
S> I want to use a variable as a regular expression because I want user
S> to be able to specify the regular expression in command line.
TJM>                                                   ^^^^^^^^^^^^^^^
TJM>                                                   ^^^^^^^^^^^^^^^
>> Be careful, if the user can type any regular expression, they can
>> execute plenty of Perl code.

TJM> They already have command line access, so users can already
TJM> execute plenty of Perl code.

It's not the same thing.  The command line can easily be

sudo script.pl regex-here

After reading `perldoc perlre' more carefully, though, it seems that
this particular feature is disabled when the regex has an interpolated
variable in it, and has to be explicitly turned on.  So it's not so bad
for the general case.

Ted


------------------------------

Date: Wed, 25 Mar 2009 18:23:48 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Invoking an SSH client by clicking a URL Link
Message-Id: <ke9q96-r9a.ln1@osiris.mauzo.dyndns.org>


Quoth cyrusgreats@gmail.com:
> Doe anyone know how to invoke an SSH client by clicking a URL Link.
> I'm working on web page and wrote some perl cgi and I need to invoke
> an ssh to send command to ssh server or client!

Do you want the ssh command to be invoked on the web server or the
client? 

If the latter, then this needs to be a function of the browser you are
using: some browsers (Firefox and IE, certainly) allow you to set up
arbitrary handlers for given URL schemes, but this would need to be done
on each machine your site was viewed from.

If the former, then you just need a link to a CGI (or something else
server-side) that uses one of the many SSH modules on CPAN to do what
you want. Be sure to arrange for the request to be a POST, rather than a
GET, since this is not an idempotent action.

Ben



------------------------------

Date: Wed, 25 Mar 2009 12:58:25 -0700 (PDT)
From: cyrusgreats@gmail.com
Subject: Re: Invoking an SSH client by clicking a URL Link
Message-Id: <95d1ac8b-f4ff-4466-ab67-34300bf218bf@c36g2000yqn.googlegroups.com>

On Mar 25, 11:23=A0am, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth cyrusgre...@gmail.com:
>
> > Doe anyone know how to invoke an SSH client by clicking a URL Link.
> > I'm working on web page and wrote some perl cgi and I need to invoke
> > an ssh to send command to ssh server or client!
>
> Do you want the ssh command to be invoked on the web server or the
> client?
>
> If the latter, then this needs to be a function of the browser you are
> using: some browsers (Firefox and IE, certainly) allow you to set up
> arbitrary handlers for given URL schemes, but this would need to be done
> on each machine your site was viewed from.
>
> If the former, then you just need a link to a CGI (or something else
> server-side) that uses one of the many SSH modules on CPAN to do what
> you want. Be sure to arrange for the request to be a POST, rather than a
> GET, since this is not an idempotent action.
>
> Ben


Thanks Ben what I'm looking for is, say from page user can click on a
link in which it sends a command to Linux shell server something like
below perhaps!

<A HREF=3D"ssh://ssh_cmd.cgi">Get directory list></A>

or perhaps
<form name=3Dmyssh method=3Dpost action=3D"ssh_cmd.cgi">


------------------------------

Date: 25 Mar 2009 20:32:51 GMT
From: jt@toerring.de (Jens Thoms Toerring)
Subject: Re: Invoking an SSH client by clicking a URL Link
Message-Id: <72vinjFrefh1U1@mid.uni-berlin.de>

cyrusgreats@gmail.com wrote:
> On Mar 25, 11:23 am, Ben Morrow <b...@morrow.me.uk> wrote:
> > Quoth cyrusgre...@gmail.com:
> >
> > > Doe anyone know how to invoke an SSH client by clicking a URL Link.
> > > I'm working on web page and wrote some perl cgi and I need to invoke
> > > an ssh to send command to ssh server or client!
> >
> > Do you want the ssh command to be invoked on the web server or the
> > client?
> >
> > If the latter, then this needs to be a function of the browser you are
> > using: some browsers (Firefox and IE, certainly) allow you to set up
> > arbitrary handlers for given URL schemes, but this would need to be done
> > on each machine your site was viewed from.
> >
> > If the former, then you just need a link to a CGI (or something else
> > server-side) that uses one of the many SSH modules on CPAN to do what
> > you want. Be sure to arrange for the request to be a POST, rather than a
> > GET, since this is not an idempotent action.
> >
> > Ben

> Thanks Ben what I'm looking for is, say from page user can click on a
> link in which it sends a command to Linux shell server something like
> below perhaps!

> <A HREF="ssh://ssh_cmd.cgi">Get directory list></A>

This can only work if the clients browser knows what to do,
i.e. the browser would have to have an idea what to do with
the 'ssh' protocol and then the handler for this protocol
had to know what to do with the rest of the URL. That would
reduce the usefulness to the small number of clents that
have the handler you would need installed, which may re-
strict it to your private computer.

> or perhaps
> <form name=myssh method=post action="ssh_cmd.cgi">

Now, that has per se nothing to do with ssh. It just will
result in a CGI script on the web server being invoked.
In that CGI script you could, of course, use ssh to get
some data from a third machine (or execute some command
on that third machine).

It might be better if you would explaing in more detail what
exactly you're planing to do instead of asking for a method
for doing something (ssh to somewhere). Then it would be
simpler to tell what's going to work and what not and, per-
haps, to come up with alternatives.

                            Regards, Jens
-- 
  \   Jens Thoms Toerring  ___      jt@toerring.de
   \__________________________      http://toerring.de


------------------------------

Date: Wed, 25 Mar 2009 14:15:47 -0700 (PDT)
From: smallpond <smallpond@juno.com>
Subject: Re: Invoking an SSH client by clicking a URL Link
Message-Id: <2f8d0315-458b-422c-bd81-63c112ae6d4e@e3g2000vbe.googlegroups.com>

On Mar 25, 3:58 pm, cyrusgre...@gmail.com wrote:

> Thanks Ben what I'm looking for is, say from page user can click on a
> link in which it sends a command to Linux shell server

You didn't answer Ben's question.  What is "it" in the above sentence.
Your possible choices are:
 1) the browser on the client PC
 2) the perl cgi on the web server

A page or a link can't send anything since they are just data, not
programs.


------------------------------

Date: Wed, 25 Mar 2009 14:48:55 -0700 (PDT)
From: cyrusgreats@gmail.com
Subject: Re: Invoking an SSH client by clicking a URL Link
Message-Id: <dfc6a187-4bfa-4632-b2f4-1efb288bdc9e@p20g2000yqi.googlegroups.com>

On Mar 25, 2:15=A0pm, smallpond <smallp...@juno.com> wrote:
> On Mar 25, 3:58 pm, cyrusgre...@gmail.com wrote:
>
> > Thanks Ben what I'm looking for is, say from page user can click on a
> > link in which it sends a command to Linux shell server
>
> You didn't answer Ben's question. =A0What is "it" in the above sentence.
> Your possible choices are:
> =A01) the browser on the client PC
> =A02) the perl cgi on the web server
>
> A page or a link can't send anything since they are just data, not
> programs.

Ok here the scenario:

1. user launch ie from windows say to automation webpage
2. There some options/links on automation page for example - by
clicking on a link, webpagee executes or send a command or run script
on remote linux server
3. the result of the above commands are printed into wepage

I've already wrote the page and need invoke ssh from webpage to send
command to remote linux server, hope I answered all your questions



------------------------------

Date: 25 Mar 2009 22:17:43 GMT
From: jt@toerring.de (Jens Thoms Toerring)
Subject: Re: Invoking an SSH client by clicking a URL Link
Message-Id: <72vos7Fs9049U1@mid.uni-berlin.de>

cyrusgreats@gmail.com wrote:
> On Mar 25, 2:15 pm, smallpond <smallp...@juno.com> wrote:
> > On Mar 25, 3:58 pm, cyrusgre...@gmail.com wrote:
> >
> > > Thanks Ben what I'm looking for is, say from page user can click on a
> > > link in which it sends a command to Linux shell server
> >
> > You didn't answer Ben's question.  What is "it" in the above sentence.
> > Your possible choices are:
> >  1) the browser on the client PC
> >  2) the perl cgi on the web server
> >
> > A page or a link can't send anything since they are just data, not
> > programs.

> Ok here the scenario:

> 1. user launch ie from windows say to automation webpage
> 2. There some options/links on automation page for example - by
> clicking on a link, webpagee executes or send a command or run script
> on remote linux server

Is it a remote machine that the web server has access to (via ssh)
or is it some random machine the client with the browser has
permissions to access only? The later variant would be a lot
more difficult and would open up a whole can of worms security-
wise...

> 3. the result of the above commands are printed into wepage

> I've already wrote the page and need invoke ssh from webpage to send
> command to remote linux server, hope I answered all your questions

Assuming that the web server has the necessary permissions to
access the remote machine where the command is to be executed
using a CGI script (invoked via a POST request from the browser)
is the way to go. In that CGI script you could use e.g. the
Net::SSH::Perl module (that's the first one I found when sea-
rching on CPAN, but there might be a range of others...) to
execute the command, read the output, and put that output
(wrapped in some HTML) into the page (simply by writing it to
stdout) that then gets send back to the browser from which the
request was send.
                                Regards, Jens
-- 
  \   Jens Thoms Toerring  ___      jt@toerring.de
   \__________________________      http://toerring.de


------------------------------

Date: Wed, 25 Mar 2009 17:23:41 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Invoking an SSH client by clicking a URL Link
Message-Id: <slrngslbnd.702.tadmc@tadmc30.sbcglobal.net>

cyrusgreats@gmail.com <cyrusgreats@gmail.com> wrote:
> On Mar 25, 2:15 pm, smallpond <smallp...@juno.com> wrote:
>> On Mar 25, 3:58 pm, cyrusgre...@gmail.com wrote:
>>
>> > Thanks Ben what I'm looking for is, say from page user can click on a
>> > link in which it sends a command to Linux shell server
>>
>> You didn't answer Ben's question.  What is "it" in the above sentence.
>> Your possible choices are:
>>  1) the browser on the client PC
>>  2) the perl cgi on the web server
>>
>> A page or a link can't send anything since they are just data, not
>> programs.
>
> Ok here the scenario:
>
> 1. user launch ie from windows say to automation webpage
> 2. There some options/links on automation page for example - by
> clicking on a link, webpagee executes or send a command or run script
> on remote linux server
> 3. the result of the above commands are printed into wepage
>
> I've already wrote the page and need invoke ssh from webpage to send
> command to remote linux server, hope I answered all your questions


Is there an answer to Ben's and smallpond's question in there somewhere?

Do you want to do ssh from a browser or do you what to do ssh from a server?


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


------------------------------

Date: Wed, 25 Mar 2009 15:38:05 -0700 (PDT)
From: cyrusgreats@gmail.com
Subject: Re: Invoking an SSH client by clicking a URL Link
Message-Id: <e14ed72f-4b41-4bbc-85db-779b8dc5f4da@k2g2000yql.googlegroups.com>

On Mar 25, 3:23=A0pm, Tad J McClellan <ta...@seesig.invalid> wrote:
> cyrusgre...@gmail.com <cyrusgre...@gmail.com> wrote:
> > On Mar 25, 2:15=A0pm, smallpond <smallp...@juno.com> wrote:
> >> On Mar 25, 3:58 pm, cyrusgre...@gmail.com wrote:
>
> >> > Thanks Ben what I'm looking for is, say from page user can click on =
a
> >> > link in which it sends a command to Linux shell server
>
> >> You didn't answer Ben's question. =A0What is "it" in the above sentenc=
e.
> >> Your possible choices are:
> >> =A01) the browser on the client PC
> >> =A02) the perl cgi on the web server
>
> >> A page or a link can't send anything since they are just data, not
> >> programs.
>
> > Ok here the scenario:
>
> > 1. user launch ie from windows say to automation webpage
> > 2. There some options/links on automation page for example - by
> > clicking on a link, webpagee executes or send a command or run script
> > on remote linux server
> > 3. the result of the above commands are printed into wepage
>
> > I've already wrote the page and need invoke ssh from webpage to send
> > command to remote linux server, hope I answered all your questions
>
> Is there an answer to Ben's and smallpond's question in there somewhere?
>
> Do you want to do ssh from a browser or do you what to do ssh from a serv=
er?
>
> --
> Tad McClellan
> email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"

I want to send some commands to be executed using ssh from browser (in
this case windows) to server (linux).
regards, ssh authentication I've already took care of that part means
any client ssh to server without password.


------------------------------

Date: 25 Mar 2009 23:12:04 GMT
From: jt@toerring.de (Jens Thoms Toerring)
Subject: Re: Invoking an SSH client by clicking a URL Link
Message-Id: <72vs24Fse4fnU1@mid.uni-berlin.de>

cyrusgreats@gmail.com wrote:
> On Mar 25, 3:23 pm, Tad J McClellan <ta...@seesig.invalid> wrote:
> > cyrusgre...@gmail.com <cyrusgre...@gmail.com> wrote:
> > > On Mar 25, 2:15 pm, smallpond <smallp...@juno.com> wrote:
> > >> On Mar 25, 3:58 pm, cyrusgre...@gmail.com wrote:
> >
> > >> > Thanks Ben what I'm looking for is, say from page user can click on a
> > >> > link in which it sends a command to Linux shell server
> >
> > >> You didn't answer Ben's question.  What is "it" in the above sentence.
> > >> Your possible choices are:
> > >>  1) the browser on the client PC
> > >>  2) the perl cgi on the web server
> >
> > >> A page or a link can't send anything since they are just data, not
> > >> programs.
> >
> > > Ok here the scenario:
> >
> > > 1. user launch ie from windows say to automation webpage
> > > 2. There some options/links on automation page for example - by
> > > clicking on a link, webpagee executes or send a command or run script
> > > on remote linux server
> > > 3. the result of the above commands are printed into wepage
> >
> > > I've already wrote the page and need invoke ssh from webpage to send
> > > command to remote linux server, hope I answered all your questions
> >
> > Is there an answer to Ben's and smallpond's question in there somewhere?
> >
> > Do you want to do ssh from a browser or do you what to do ssh from a server?

> I want to send some commands to be executed using ssh from browser (in
> this case windows) to server (linux).
> regards, ssh authentication I've already took care of that part means
> any client ssh to server without password.

The browser by itself does not send commands. The browser can only
send requests to a web server or (if the browser allows it) invoke
some external programs for dealing with certain URLs the browser
doesn't know how to handle by itself (ssh is one of them).

Let's look again at the two scenarios:

a) The browser sends a (POST) request to the web server that makes
   the web server execute a CGI script written in Perl. Within that
   script you can ssh to any third machine the web server has access
   to to your hearts desires. That way you could easily execute a
   command on the third machine, read in the what it returns and
   assemble a web page that then gets send back to the browser that
   initiated the request. I already tried to give you some hints on
   how to deal with that in a previous post.

b) On the same machine where the browser is running you have bound
   a certain application (perhaps written in Perl) to a certain
   protocol (ssh seems to be what you want). This requires that
   this application is installed on the the machine the browser is
   running on and that the browser is set up to invoke this appli-
   cation when being asked to deal with the ssh protocol. That's
   like when you click on an email address and then your favorite
   email program pops up: the browser is set up to start the email
   program whenever you click on a link that starts with 'mailto:'.

You still have not given any indication of what you're up to.
And just talking about 'ssh' won't make it any clearer.

Should you really have set up a Linux box to allow logins via ssh
without a password from everywhere on the internet then I can only
strongly recommend that you take it off tne net *NOW* or in a few
minutes it will be pwnded (or it already is).

                                Regards, Jens
-- 
  \   Jens Thoms Toerring  ___      jt@toerring.de
   \__________________________      http://toerring.de


------------------------------

Date: Wed, 25 Mar 2009 23:40:49 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Invoking an SSH client by clicking a URL Link
Message-Id: <11sq96-vod.ln1@osiris.mauzo.dyndns.org>


Quoth cyrusgreats@gmail.com:
> 
> I want to send some commands to be executed using ssh from browser (in
> this case windows) to server (linux).
> regards, ssh authentication I've already took care of that part means
> any client ssh to server without password.

I think you need to stop *now* and consult someone who actually knows
what they're doing. Going about this with the level of understanding you
apparently have will almost certainly lead to serious security holes in
your setup.

Ben



------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 2297
***************************************


home help back first fref pref prev next nref lref last post