[jcifs] Re: Remote command Execution?
Michael B Allen
mba2000 at ioplex.com
Fri Sep 10 19:14:41 GMT 2004
On Fri, 10 Sep 2004 16:19:19 +0200
"michael melhem" <michaelm at managesoft.com> wrote:
> Hi Mike, et al.
> Remote execution via atsvc + jarapac is working fine for me. However there
> are two issues:
> 1. There appears to be no way of running tasks immediately using atsvc.
> the best I can do is work out the time of the remote windows machine and
> calculate a invocation time + 2mins. I can get the time from the remote
> windows machine using NET TIME. (Seems strange that relative or immediate
> scheduling is not supported by the standard windows schedulers)
It's gotta be better than 2 minutes. If I look at the clock and run an
at command in a cmd window for the next minute, the instant the clock
changes the command runs.
Add a method to SmbFile that returns
tree.session.transport.server.serverTime. Compute the milliseconds
since 12am (compute the 12am today in milliseconds and subtract from
serverTime) and add 10 seconds. I bet it works. At some point you have
to be concerned that network latency could cause your message to miss
the time window so you'll want to be able to tune the delay.
> 2. The other problem with this is that you cannot get the return code of
> remote command. This we might just have to live with.
That's the at command. Make a bat that echos the return code and redirects
output to a file in temp and then flips the archive bit on or creates and
'.end' file when the command completes. Then retrieve it to get the output.
> An aside:
> I think its possible using RPC to remotely install and start an arbitrary
> service on a remote windows machine (from a windows machine). Is it
> possible to do something similar from Linux, using jarapac perhaps? This
> could be another way to implement remote command execution by installing
> the appropriate service.
I think so. You could try to MIDLize the appropriate samba4 svcctl.idl
There's probably a good way to do this. I recommand asking on the
microsoft.public.* newsgroups how to remotely execute a command (don't
mention anything about Java). Then write a little Win32 program to do it and
take a packet capture. Look at what messages are used and see if there are
Greedo shoots first? Not in my Star Wars.
More information about the jcifs