comp.lang.ada
 help / color / mirror / Atom feed
* SSH Sessions ?
@ 2004-08-09 18:32 Chris Humphries
  2004-08-09 19:12 ` Georg Bauhaus
  0 siblings, 1 reply; 15+ messages in thread
From: Chris Humphries @ 2004-08-09 18:32 UTC (permalink / raw)


Hello,

   Has anyone written or have a way to do SSH sessions via ADA?

   Looking to: 1) connect to servers from having the username, password, and ip
               2) execute one command
               3) save the text/status returned from the command

Thanks,
Chris Humphries



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: SSH Sessions ?
  2004-08-09 18:32 SSH Sessions ? Chris Humphries
@ 2004-08-09 19:12 ` Georg Bauhaus
  2004-08-10  1:54   ` Chris Humphries
  2004-08-10  4:32   ` Adam Ruth
  0 siblings, 2 replies; 15+ messages in thread
From: Georg Bauhaus @ 2004-08-09 19:12 UTC (permalink / raw)


Chris Humphries <chris@unixfu.net> wrote:
:   Has anyone written or have a way to do SSH sessions via ADA?
: 
:   Looking to: 1) connect to servers from having the username, password, and ip
:               2) execute one command
:               3) save the text/status returned from the command

Not exactly like ssh, but would SOAP via HTTPS be an option?
http://libre.act-europe.fr/aws/aws-2.0p.html#Using%20SOAP


-- Georg



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: SSH Sessions ?
  2004-08-09 19:12 ` Georg Bauhaus
@ 2004-08-10  1:54   ` Chris Humphries
  2004-08-10  2:49     ` Stephen Leake
  2004-08-11  6:57     ` Andreas Almroth
  2004-08-10  4:32   ` Adam Ruth
  1 sibling, 2 replies; 15+ messages in thread
From: Chris Humphries @ 2004-08-10  1:54 UTC (permalink / raw)


Georg Bauhaus <sb463ba@l1-hrz.uni-duisburg.de> wrote in message news:<cf8iab$qav$1@a1-hrz.uni-duisburg.de>...
> Chris Humphries <chris@unixfu.net> wrote:
> :   Has anyone written or have a way to do SSH sessions via ADA?
> : 
> :   Looking to: 1) connect to servers from having the username, password, and ip
> :               2) execute one command
> :               3) save the text/status returned from the command
> 
> Not exactly like ssh, but would SOAP via HTTPS be an option?
> http://libre.act-europe.fr/aws/aws-2.0p.html#Using%20SOAP
> 

Thank you for the information, yet I am afraid it must be SSH[2].

I would like to use ADA instead of Perl to log into machines on
our network and check various things (kernel versions [we have our
own rolled] and security checks) for our clients. I work at an
isp and webhosting company (of a nice size) and would like to
login with login information (which i already have in a system
i wrote) via SSH. Installing software on client computers will
not be an option :)

I am new to ADA, but it seems like an awesome language. Much easier
to read and understand what is going on than most other languages I
know (including Python).

Would like to move from Perl for most of the core company software
needs to Ruby or ADA.

I was told I could use C libraries and call methods from them from
within ADA. Is this true, and if so, could I use the existing 
openssl/openssh libraries to implement SSH in ADA? That seems like
too much work and why not just use Perl (best tool for the job/time?).

> 
> -- George

SOAP over HTTPS does sound good though for data transmission over
secure channels. Only used plain bare XML for data and meta-data,
nothing more. Guess I should look more into it ;)



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: SSH Sessions ?
  2004-08-10  1:54   ` Chris Humphries
@ 2004-08-10  2:49     ` Stephen Leake
  2004-08-11  6:57     ` Andreas Almroth
  1 sibling, 0 replies; 15+ messages in thread
From: Stephen Leake @ 2004-08-10  2:49 UTC (permalink / raw)
  To: comp.lang.ada

chris@unixfu.net (Chris Humphries) writes:

> I would like to use ADA instead of Perl to log into machines on
> our network and check various things (kernel versions [we have our
> own rolled] and security checks) for our clients. I work at an
> isp and webhosting company (of a nice size) and would like to
> login with login information (which i already have in a system
> i wrote) via SSH. Installing software on client computers will
> not be an option :)

Ok. In general, a good idea to use Ada.

> I am new to ADA, but it seems like an awesome language. Much easier
> to read and understand what is going on than most other languages I
> know (including Python).

Yes!

> Would like to move from Perl for most of the core company software
> needs to Ruby or ADA.
> 
> I was told I could use C libraries and call methods from them from
> within ADA. Is this true, 

Yes.

> and if so, could I use the existing openssl/openssh libraries to
> implement SSH in ADA? 

Yes.

> That seems like too much work and why not just use Perl (best tool
> for the job/time?).

That is your call. As you have seen, Perl gets you going faster,
because a lot of libraries already have Perl bindings (other people
have already done the work). But it's harder to maintain in the long
run.

You can try to run the command line ssh from within Ada, using the
GNAT.Expect package, or GNAT.Os_Lib.Spawn. You can capture the output
and parse it, using GNAT.Regexp or GNAT.Spitbol or just
Ada.Strings.Fixed. That might still be better than Perl.

If you do decide to write Ada bindings to the C ssh libraries, be sure
to post them here, or contribute them to the OpenSSH code repository.
Then we can take advantage of your work :).

-- 
-- Stephe




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: SSH Sessions ?
  2004-08-09 19:12 ` Georg Bauhaus
  2004-08-10  1:54   ` Chris Humphries
@ 2004-08-10  4:32   ` Adam Ruth
  2004-08-10 12:58     ` Marc A. Criley
  1 sibling, 1 reply; 15+ messages in thread
From: Adam Ruth @ 2004-08-10  4:32 UTC (permalink / raw)


In article <cf8iab$qav$1@a1-hrz.uni-duisburg.de>,
 Georg Bauhaus <sb463ba@l1-hrz.uni-duisburg.de> wrote:

> Chris Humphries <chris@unixfu.net> wrote:
> :   Has anyone written or have a way to do SSH sessions via ADA?
> : 
> :   Looking to: 1) connect to servers from having the username, password, and 
> :   ip
> :               2) execute one command
> :               3) save the text/status returned from the command
> 
> Not exactly like ssh, but would SOAP via HTTPS be an option?
> http://libre.act-europe.fr/aws/aws-2.0p.html#Using%20SOAP
> 
> 
> -- Georg

I'm doing this very thing myself, and I'm just using the command line 
version of ssh.  I execute it using the system call (the c library 
system(const char *command) call).  It's pretty straight forward, since 
I don't need to do much that's complicated, just execute a remote 
command line program as though it was being executed on my local command 
line.

2 caveats.  First, I use public key authentication instead of a 
password.  Second, I pipe my error stream to standard output (using 
2>&1), so stderr and stdout are all mucnched together.  But that works 
fine for what I'm doing (it's simpler than using one of the popen 
commands).

If you'd like some more details, I'll be glad to offer them.

-- 
--
Adam Ruth
adamruth at mac dot com



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: SSH Sessions ?
  2004-08-10  4:32   ` Adam Ruth
@ 2004-08-10 12:58     ` Marc A. Criley
  2004-08-11 13:35       ` Chris Humphries
  2004-08-13 11:48       ` Using Jim Rogers' "Ada Binding to Pipes"? (Was: SSH Sessions?) Jacob Sparre Andersen
  0 siblings, 2 replies; 15+ messages in thread
From: Marc A. Criley @ 2004-08-10 12:58 UTC (permalink / raw)


"Adam Ruth" <adam.ruth@mac.com> wrote:

> I'm doing this very thing myself, and I'm just using the command line
> version of ssh.  I execute it using the system call (the c library
> system(const char *command) call).  It's pretty straight forward, since
> I don't need to do much that's complicated, just execute a remote
> command line program as though it was being executed on my local command
> line.

Just want to reacquaint everyone about the existence of Jim Rogers' "Ada
Binding to Pipes" (http://www.adapower.com/reuse/pipes.html). You can issue
a command and all the output is caught and easily read back in for
post-processing.

It's incredibly easy to use, effective and reliable, and I use it almost
exclusively whenever I need to issue commands from within an Ada program.
Works great, highly, highly recommended.  (Thanks Jim!)

Marc A. Criley
McKae Technologies
www.mckae.com







^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: SSH Sessions ?
  2004-08-10  1:54   ` Chris Humphries
  2004-08-10  2:49     ` Stephen Leake
@ 2004-08-11  6:57     ` Andreas Almroth
  1 sibling, 0 replies; 15+ messages in thread
From: Andreas Almroth @ 2004-08-11  6:57 UTC (permalink / raw)


Chris Humphries wrote:
> Georg Bauhaus <sb463ba@l1-hrz.uni-duisburg.de> wrote in message news:<cf8iab$qav$1@a1-hrz.uni-duisburg.de>...
> 
>>Chris Humphries <chris@unixfu.net> wrote:
>>:   Has anyone written or have a way to do SSH sessions via ADA?
>>: 
> 
> I was told I could use C libraries and call methods from them from
> within ADA. Is this true, and if so, could I use the existing 
> openssl/openssh libraries to implement SSH in ADA? That seems like
> too much work and why not just use Perl (best tool for the job/time?).
> 

Calling C API is generally not a problem if properly done.
To answer your question; As there is no, to my knowledge, API to SSH, 
you will either first have to write a binding to OpenSSL, or try to 
re-use the SSL part of AWS, and then code the SSH functionality on top. 
This would be really something nice for the Ada community though, but 
perhaps a bit too much to ask for.

The other way is to call the ssh client using either system or pipes, as 
  the other messages in this thread points out. I think this might be 
the way that Perl and Java does it.

/Andreas





^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: SSH Sessions ?
  2004-08-10 12:58     ` Marc A. Criley
@ 2004-08-11 13:35       ` Chris Humphries
  2004-08-13 11:48       ` Using Jim Rogers' "Ada Binding to Pipes"? (Was: SSH Sessions?) Jacob Sparre Andersen
  1 sibling, 0 replies; 15+ messages in thread
From: Chris Humphries @ 2004-08-11 13:35 UTC (permalink / raw)


Thank you everyone. You have been very helpful :)

"Marc A. Criley" <mcNOSPAM@mckae.com> wrote in message news:<2nrv4rF3hamgU1@uni-berlin.de>...
> "Adam Ruth" <adam.ruth@mac.com> wrote:
> 
> > I'm doing this very thing myself, and I'm just using the command line
> > version of ssh.  I execute it using the system call (the c library
> > system(const char *command) call).  It's pretty straight forward, since
> > I don't need to do much that's complicated, just execute a remote
> > command line program as though it was being executed on my local command
> > line.
> 
> Just want to reacquaint everyone about the existence of Jim Rogers' "Ada
> Binding to Pipes" (http://www.adapower.com/reuse/pipes.html). You can issue
> a command and all the output is caught and easily read back in for
> post-processing.
> 
> It's incredibly easy to use, effective and reliable, and I use it almost
> exclusively whenever I need to issue commands from within an Ada program.
> Works great, highly, highly recommended.  (Thanks Jim!)
> 
> Marc A. Criley
> McKae Technologies
> www.mckae.com



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Using Jim Rogers' "Ada Binding to Pipes"? (Was: SSH Sessions?)
  2004-08-10 12:58     ` Marc A. Criley
  2004-08-11 13:35       ` Chris Humphries
@ 2004-08-13 11:48       ` Jacob Sparre Andersen
  2004-08-13 17:44         ` Marc A. Criley
  1 sibling, 1 reply; 15+ messages in thread
From: Jacob Sparre Andersen @ 2004-08-13 11:48 UTC (permalink / raw)


Marc A. Criley wrote:

> Just want to reacquaint everyone about the existence of Jim Rogers'
> "Ada Binding to Pipes"
> (http://www.adapower.com/reuse/pipes.html). You can issue a command
> and all the output is caught and easily read back in for
> post-processing.

I have some problems getting it to link (using GNAT/Linux/IA32).  This
looks like the critical section in the output from `gnatmake`:

----------
gnatlink pipe_commands_test.ali
./pipe_commands.o(.text+0x3f4): In function `pipe_commands__read_next':
: undefined reference to `c_constant_eof'
collect2: ld returned 1 exit status
gnatlink: cannot call /usr/gnat/gnat-501p-jmc/bin/gcc
gnatmake: *** link failed.
----------

Any suggestions?

Jacob
-- 
"You've got to build bypasses!"



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Using Jim Rogers' "Ada Binding to Pipes"? (Was: SSH Sessions?)
  2004-08-13 11:48       ` Using Jim Rogers' "Ada Binding to Pipes"? (Was: SSH Sessions?) Jacob Sparre Andersen
@ 2004-08-13 17:44         ` Marc A. Criley
  2004-08-14 18:45           ` James E. Hopper
  2004-08-16 16:28           ` Using Jim Rogers' "Ada Binding to Pipes"? (Was: SSH Sessions?) Anh_Vo
  0 siblings, 2 replies; 15+ messages in thread
From: Marc A. Criley @ 2004-08-13 17:44 UTC (permalink / raw)



"Jacob Sparre Andersen" <sparre@nbi.dk> wrote:

> I have some problems getting it to link (using GNAT/Linux/IA32).  This
> looks like the critical section in the output from `gnatmake`:
>
> ----------
> gnatlink pipe_commands_test.ali
> ./pipe_commands.o(.text+0x3f4): In function `pipe_commands__read_next':
> : undefined reference to `c_constant_eof'
> collect2: ld returned 1 exit status
> gnatlink: cannot call /usr/gnat/gnat-501p-jmc/bin/gcc
> gnatmake: *** link failed.
> ----------
>
> Any suggestions?

Now that you mention it, I vaguely recall having to deal with that problem.

I _think_ the problem was that the code interfaced to a symbol in the GNAT
library called "c_constant_eof". As the Pipes package is a few years old,
GNAT has undergone several version upgrades since then, and that symbol is
no longer available.

Waitaminnit, oh, you are soooooo lucky!

I carry the DTraq code around with me on one of those flash memory drives,
and since it uses Pipes I pulled up the code.  Here's the comment I put in:

-- MODIFIED: 26 Jan 2003   Marc A. Criley
--    c_constant_EOF no longer available.  (Defined by GNAT 3.13p?  No
longer
--    available in 3.15p?)  Replaced with hard-coded -1, as per stdio.h

There you go!

Marc A. Criley
McKae Technologies
www.mckae.com





^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Using Jim Rogers' "Ada Binding to Pipes"? (Was: SSH Sessions?)
  2004-08-13 17:44         ` Marc A. Criley
@ 2004-08-14 18:45           ` James E. Hopper
  2004-08-17 15:29             ` Using Jim Rogers' "Ada Binding to Pipes"? Jacob Sparre Andersen
  2004-08-16 16:28           ` Using Jim Rogers' "Ada Binding to Pipes"? (Was: SSH Sessions?) Anh_Vo
  1 sibling, 1 reply; 15+ messages in thread
From: James E. Hopper @ 2004-08-14 18:45 UTC (permalink / raw)


when building and running pipes after putting in the fix previously
mentioned in this thread i get

"Attempt illegal input from a pipe to the tee command:
Detected improper attempt to read from a pipe opened for write only."


from looking at the test program this seems the correct response as
written, even though its not obvous from the output that this is
expected.  code in question is:

      FileStream := execute(command4, write_file);
      begin
         print_buf(FileStream);
         exception
            when Access_Error =>
               put_line ("Detected improper attempt to read from a pipe
opened for write only.");
      end;


FileStream is opened for write, then in print_buf the code attempts to
read from the stream.  

is the test trying to force an error to demonstate that it works, or is
there something in using this with osx that makes this wrong?

thanks jim



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Using Jim Rogers' "Ada Binding to Pipes"? (Was: SSH Sessions?)
  2004-08-13 17:44         ` Marc A. Criley
  2004-08-14 18:45           ` James E. Hopper
@ 2004-08-16 16:28           ` Anh_Vo
  2004-08-17 15:28             ` Jacob Sparre Andersen
  1 sibling, 1 reply; 15+ messages in thread
From: Anh_Vo @ 2004-08-16 16:28 UTC (permalink / raw)


"Marc A. Criley" <mcNOSPAM@mckae.com> wrote in message news:<2o4d0kF6f1hsU1@uni-berlin.de>...
> "Jacob Sparre Andersen" <sparre@nbi.dk> wrote:
> 
> > I have some problems getting it to link (using GNAT/Linux/IA32).  This
> > looks like the critical section in the output from `gnatmake`:
> >
> > ----------
> > gnatlink pipe_commands_test.ali
> > ./pipe_commands.o(.text+0x3f4): In function `pipe_commands__read_next':
> > : undefined reference to `c_constant_eof'
> > collect2: ld returned 1 exit status
> > gnatlink: cannot call /usr/gnat/gnat-501p-jmc/bin/gcc
> > gnatmake: *** link failed.
> > ----------
>  
> -- MODIFIED: 26 Jan 2003   Marc A. Criley
> --    c_constant_EOF no longer available.  (Defined by GNAT 3.13p?  No
> longer
> --    available in 3.15p?)  Replaced with hard-coded -1, as per stdio.h
> 
for GNAT 3.4.0 I use pragma Import (C, c_constant_EOF,
"__gnat_constant_eof"); instead of pragma Import (C, c_constant_EOF).
A. Vo



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Using Jim Rogers' "Ada Binding to Pipes"? (Was: SSH Sessions?)
  2004-08-16 16:28           ` Using Jim Rogers' "Ada Binding to Pipes"? (Was: SSH Sessions?) Anh_Vo
@ 2004-08-17 15:28             ` Jacob Sparre Andersen
  0 siblings, 0 replies; 15+ messages in thread
From: Jacob Sparre Andersen @ 2004-08-17 15:28 UTC (permalink / raw)


Anh Vo wrote:

> for GNAT 3.4.0 I use pragma Import (C, c_constant_EOF,
> "__gnat_constant_eof"); instead of pragma Import (C,
> c_constant_EOF).

Thanks.  That seems to work fine.

Jacob
-- 
"Three can keep a secret if two of them are dead."



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Using Jim Rogers' "Ada Binding to Pipes"?
  2004-08-14 18:45           ` James E. Hopper
@ 2004-08-17 15:29             ` Jacob Sparre Andersen
  2004-08-18  1:15               ` James E. Hopper
  0 siblings, 1 reply; 15+ messages in thread
From: Jacob Sparre Andersen @ 2004-08-17 15:29 UTC (permalink / raw)


James E. Hopper wrote:

> "Attempt illegal input from a pipe to the tee command:
> Detected improper attempt to read from a pipe opened for write only."
[...]
> is the test trying to force an error to demonstate that it works, or
> is there something in using this with osx that makes this wrong?

I get the same error message on Linux, so it is probably not just a
problem with Mac OS X.

Jacob
-- 
"Three can keep a secret if two of them are dead."



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Using Jim Rogers' "Ada Binding to Pipes"?
  2004-08-17 15:29             ` Using Jim Rogers' "Ada Binding to Pipes"? Jacob Sparre Andersen
@ 2004-08-18  1:15               ` James E. Hopper
  0 siblings, 0 replies; 15+ messages in thread
From: James E. Hopper @ 2004-08-18  1:15 UTC (permalink / raw)


Thanks good to know.  it looks like a coding error in the test program.  

best jim

In article <ply8kdixzr.fsf_-_@sparre.crs4.it>, Jacob Sparre Andersen
<sparre@nbi.dk> wrote:

> I get the same error message on Linux, so it is probably not just a
> problem with Mac OS X.



^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2004-08-18  1:15 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-09 18:32 SSH Sessions ? Chris Humphries
2004-08-09 19:12 ` Georg Bauhaus
2004-08-10  1:54   ` Chris Humphries
2004-08-10  2:49     ` Stephen Leake
2004-08-11  6:57     ` Andreas Almroth
2004-08-10  4:32   ` Adam Ruth
2004-08-10 12:58     ` Marc A. Criley
2004-08-11 13:35       ` Chris Humphries
2004-08-13 11:48       ` Using Jim Rogers' "Ada Binding to Pipes"? (Was: SSH Sessions?) Jacob Sparre Andersen
2004-08-13 17:44         ` Marc A. Criley
2004-08-14 18:45           ` James E. Hopper
2004-08-17 15:29             ` Using Jim Rogers' "Ada Binding to Pipes"? Jacob Sparre Andersen
2004-08-18  1:15               ` James E. Hopper
2004-08-16 16:28           ` Using Jim Rogers' "Ada Binding to Pipes"? (Was: SSH Sessions?) Anh_Vo
2004-08-17 15:28             ` Jacob Sparre Andersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox