El comando
wc (word count) de unix/linux con la clausula
-l cuenta numero de líneas.
Si rediriges la salida asi:
wc -l archivo > salida.txt tendras el resultado en el fichero de
salida.txt.
Para ejecutar un comando remoto en una máquina unix/linux utiliza el objeto COMM RemoteShell.
- Code: Select all Expand view
oRemoteShell:=CreateObject("WScript.Shell")
oRemoteShell:Run("cmd /C rsh Equipo -l NombreDeUsuario -n wc -l archivo > salida.txt & exit",0,.F.)
oRemoteShell:=nil
El fichero de
salida.txt se queda en el PC desde el que ejecutas el RemoteShell. Si en vez de poner "
>" pones "
>>" el fichero se queda en el servidor.
La segunda línea del código que te pongo la puedes modificar según donde quieras la salida.
En el PC desde el que ejecutas la RemoreShell (c:\tmp\salida.txt):
- Code: Select all Expand view
oRemoteShell:Run("cmd /C rsh Equipo -l NombreDeUsuario -n wc -l archivo > c:\tmp\salida.txt & exit",0,.F.)
O en el servidor, pero tendras que traerte por FTP el fichero (/home/tmp/salida.txt):
- Code: Select all Expand view
oRemoteShell:Run("cmd /C rsh Equipo -l NombreDeUsuario -n wc -l archivo >> /home/tmp/salida.txt & exit",0,.F.)
NOTAS:
cmd /C Ejecuta el comando especificado mediante el parámetro cadena y, después, se detiene.
rsh Ejecuta comandos en equipos remotos que ejecutan en el servicio RSH o un equivalente.
Sintaxis:
rsh [Equipo] [-l NombreDeUsuario] [-n] [Comando]Equipo Dirección IP del equipo remoto.
NombreDeUsuario Nombre de usuario, no hace falta password.
& exit salida de "consola" del ordenador remoto.
Según la documentación del MSDN
http://msdn.microsoft.com/en-us/library/d5fk67ky(VS.85).aspx esto es lo que dice sobre el método RUN del RemoteShell:
object:Run(strCommand, [intWindowStyle], [bWaitOnReturn])strCommand: String value indicating the command line you want to run. You must include any parameters you want to pass to the executable file.
intWindowStyle: Optional. Integer value indicating the appearance of the program's window. Note that not all programs make use of this information.
Value 0= Hides the window and activates another window.bWaitOnReturn: Optional. Boolean value indicating whether the script should wait for the program to finish executing before continuing to the next statement in your script. If set to true, script execution halts until the program finishes, and Run returns any error code returned by the program. If set to false (the default), the Run method returns immediately after starting the program, automatically returning 0 (not to be interpreted as an error code).
Mi abuelo decía: Los aviones vuelan porque Dios quiere, y los helicópteros ni Dios sabe porque vuelan.
FWH 16.02, xHarbour 1.2.3, Harbour 3.2.0, WorkShop 4.5, AJ Make 0.30, Borlan BCC 7.00, VisualStudio 2013