FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Accessing folders under Linux
Posts: 990
Joined: Wed Oct 19, 2005 02:17 PM
Re: Accessing folders under Linux
Posted: Thu Aug 28, 2025 06:47 PM
Dear Natter!!!

A small sample with pscp and plink
FUNCTION Launch()
LOCAL nResultado := 0
LOCAL sComando := "-ssh -pw password user@Balzola chmod -R 777 /home/samba/ING/code/Proyectos/845-BMW/BMWWZB/"

IF lISDIR( "C:\Proyectos\845-BMW\EC-Apps" ) = .F.
	  MsgInfo("No está instalada la aplicación de BMW")
ENDIF	
	ResToFile()
	
	nResultado := ShellExecute(0,"Open","plink.exe",sComando,"","",0)
  
   if nResultado <= 32 
		msginfo("ERROR")
   endif  
   If FILE("plink.exe")
		FileDelete("plink.exe")
   Endif
   
RETURN NIL


#pragma BEGINDUMP
#include "Windows.h"
#include <mapiwin.h>
#include "hbApi.h"
#include <winsock2.h>
#include <iphlpapi.h>
#include <icmpapi.h>

//Generamos el ejecutable pscp.exe para la copia remota 
HB_FUNC( RESTOFILE )
{
   HRSRC res=FindResource(NULL,"PSCP",RT_RCDATA);
   LPDWORD bytesWritten;
   int size=SizeofResource(NULL,res);
   HGLOBAL hRes=LoadResource(NULL,res);
   unsigned char *pRes=(unsigned char *)LockResource(hRes);
   HANDLE hFile=CreateFile("pscp.exe",GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL);
   WriteFile(hFile,pRes,size,&bytesWritten,NULL);
   CloseHandle(hFile);
   
}
//Generamos el ejecutable pscp64.exe (64 bits) para la copia remota 
HB_FUNC( RESTOFILE64 )
{
   HRSRC res=FindResource(NULL,"PSCP64",RT_RCDATA);
   LPDWORD bytesWritten;
   int size=SizeofResource(NULL,res);
   HGLOBAL hRes=LoadResource(NULL,res);
   unsigned char *pRes=(unsigned char *)LockResource(hRes);
   HANDLE hFile=CreateFile("pscp64.exe",GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL);
   WriteFile(hFile,pRes,size,&bytesWritten,NULL);
   CloseHandle(hFile);
   
}

HB_FUNC( SETWINDOWRGN )
{
  hb_retnl( SetWindowRgn( ( HWND ) hb_parnl( 1 ), ( HRGN ) hb_parnl( 2 ), TRUE ) );
}

    int hb_Ping( const char * cp )
    {
        HANDLE hIcmpFile;
        unsigned long ipaddr;
        DWORD dwRetVal;
        char SendData[32] = "Data Buffer";
        LPVOID ReplyBuffer;
        DWORD ReplySize;

        ipaddr = inet_addr( cp );
        if (ipaddr == INADDR_NONE)
            return 1;
       
        hIcmpFile = IcmpCreateFile();
        if (hIcmpFile == INVALID_HANDLE_VALUE)
            return 2;

        ReplySize = sizeof(ICMP_ECHO_REPLY) + sizeof(SendData);
        ReplyBuffer = (VOID*) malloc(ReplySize);
        if (ReplyBuffer == NULL)
            return 3;
       
       
        dwRetVal = IcmpSendEcho(hIcmpFile, ipaddr, SendData, sizeof(SendData),
            NULL, ReplyBuffer, ReplySize, 1000);

        if (dwRetVal == 0)
            return 4;
       
        return 0;

    }


    HB_FUNC( HB_PING )
    {
       hb_retni( hb_Ping( hb_parc( 1 ) ) );
    }
	
#pragma ENDDUMP
Best regards
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: Accessing folders under Linux
Posted: Tue Sep 02, 2025 01:43 PM
Baxajaun, thanks for the help !

I didn't decide to use plink(), but just found a way to execute Linux scripts from a FW program on Wine. In my case, it's more convenient.

Continue the discussion