[fpc-pascal] Reading non-printable caracters in file (linux)
Dear. I need to read /proc/pid/cmdline files But if i use a standard function that read file with assign,readln,EOF some important non-printables caracters are not trapped with fpc readln : imapd-s-U30 if i use cat -v cat -v /proc/26328/cmdline [EMAIL PROTECTED]@[EMAIL PROTECTED]@ Did anybody has developped a function that read a file include non-printable caracters ^@ like a cat -v command line tool ? Best regards -- David Touzeau -- Linux Ubuntu 7.04 feisty FreePascal-Lazarus,perl,delphi,php artica for postfix management console (http://www.artica.fr) icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] libmilter + freepascal
Dear I'm trying to find examples using libmilter (sendmail milter) with freepascal. Does anybody have usefull links or code with it ? best regards -- David Touzeau -- Linux Ubuntu 7.04 feisty FreePascal-Lazarus,perl,delphi,php artica for postfix management console (http://www.artica.fr) icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Re: [fpc-devel] Local variable X does not seem to be initialized as a TextFile value
It's a 2.2.0 : Free Pascal Compiler version 2.2.0 [2007/08/30] for i386 Copyright (c) 1993-2007 by Florian Klaempfl /usr/lib/fpc/2.2.0/ppc386 [options] inputfile Jonas Maebe a écrit : On 28 Dec 2007, at 12:06, TOUZEAU DAVID wrote: I have many warning like (966,12) Hint: Local variable X does not seem to be initialized that X is a TextFile I understand that only X is initialized when assign() it How to prevent this warning ?? Upgrade to FPC 2.2.0 or later. Jonas -- David Touzeau -- Linux Ubuntu 7.04 feisty FreePascal-Lazarus,perl,delphi,php artica for postfix management console (http://www.artica.fr) icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] HOW TO, PROBLEM read stdin (linux) ??
Dear What is the best way to read into a memory datas from this command. /bin/myprogram /home/tests/file.txt my test program read only the first line from stdline. What i miss ??? program myprogram; {$mode objfpc}{$H+} uses Classes, SysUtils; var st: text; s: string; begin assign(st,''); reset(st); readln(st,s); writeln(s) end. -- David Touzeau -- Linux Ubuntu 7.04 feisty FreePascal-Lazarus,perl,delphi,php artica for postfix management console (http://www.artica.fr) icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] HOW TO, PROBLEM read stdin (linux) ??
Great many thanks Wanderlan Santos dos Anjos a écrit : program yourprogram; {$mode objfpc}{$H+} uses Classes, SysUtils; var st: text; s: string; begin assign(st,''); reset(st); while not eof(st) do begin // --- iterate while not en of file readln(st,s); // read only a line writeln(s); end; close(st); // --- end. -- Att, Wanderlan Santos dos Anjos On Nov 24, 2007 8:15 AM, TOUZEAU DAVID [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Dear What is the best way to read into a memory datas from this command. /bin/myprogram /home/tests/file.txt my test program read only the first line from stdline. What i miss ??? program myprogram; {$mode objfpc}{$H+} uses Classes, SysUtils; var st: text; s: string; begin assign(st,''); reset(st); readln(st,s); writeln(s) end. -- David Touzeau -- Linux Ubuntu 7.04 feisty FreePascal-Lazarus,perl,delphi,php artica for postfix management console ( http://www.artica.fr) icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org mailto:fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- * 01.41.39.04.42 * 06.20.56.74.33 * ICQ:160018849 * Skype:dtouzeau * Site technique destiné aux entreprises: http://entreprises.kaspersky.fr * Inscrivez-vous dès maintenant dans l'espace partenaires ! http://partners.kaspersky.fr (Retrouvez sur ces sites des faqs, tutoriaux, Forums et liens de téléchargement de la gamme Buiness Optimal) * * ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] How to send stdout pipe to a process ?
Dear I would like to send a TStringList.text to an external process (kind of stdout) i have an external process that require to receive datas from stdin like /home/process1 /tmp/data.txt I would like my program to send datas inserted into a Tstringlist to this process1 I think i should use Output but don't know how ? Do you think this should be answer ?? Is there a better way ? For i:=0 to List.Count-1 do begin writeln(output;list.Strings[i]); end; -- David Touzeau -- Linux Ubuntu 7.04 feisty FreePascal-Lazarus,perl,delphi,php artica for postfix management console (http://www.artica.fr) icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Best way for tail a log file
Dear I need to parse /var/log/maillog file in the same way of /bin/tail tool in order to parse some lines. What is the best way or do you have such function that follow the write lines in a file ?? Best regards -- David Touzeau -- Linux Ubuntu Dapper 6.0.6 FreePascal-Lazarus,perl,delphi,php icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Get Timestamp since 1970 (linux)
Many thanks patrick i will try it ! patrick feillant a écrit : Hello, You can do that with ? MilliSecondsBetween http://lazarus-ccr.sourceforge.net/fpcdoc/rtl/dateutils/millisecondsbetween.html Calculate the number of whole milliseconds between two DateTime values. between encodedatetime(1970,1,1,0,0,0,0) and Present I don't test, but it's probably ok. bye 2007/6/4, TOUZEAU DAVID [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]: Dear Is there a function that help me to calculate seconds since 1970 year ? exactly the same of this command : /bin/date +%s -d 20070103 best regards -- David Touzeau -- Linux Ubuntu Dapper 6.0.6 FreePascal-Lazarus,perl,delphi,php icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org mailto:fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- David Touzeau -- Linux Ubuntu Dapper 6.0.6 FreePascal-Lazarus,perl,delphi,php icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Get Timestamp since 1970 (linux)
Many thanks Seweryn, i use it var ANow,AThen : TDateTime; begin ANow:=now; AThen:=EncodeDateTime(1970, 1, 1, 0, 0, 0, 0); result:=IntTostr(SecondsBetween(ANow,AThen)-7200);//7200 for GMT +2 end; Seweryn Walentynowicz a écrit : On Mon, Jun 04, 2007 at 09:27:55AM +0200, patrick feillant wrote: MilliSecondsBetweenhttp://lazarus-ccr.sourceforge.net/fpcdoc/rtl/dateutils/millisecondsbetween.html Maybe simpler Secondsbetween() ? :o) 2007/6/4, TOUZEAU DAVID [EMAIL PROTECTED]: Is there a function that help me to calculate seconds since 1970 year ? -- David Touzeau -- Linux Ubuntu Dapper 6.0.6 FreePascal-Lazarus,perl,delphi,php icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Get Timestamp since 1970 (linux)
Dear Is there a function that help me to calculate seconds since 1970 year ? exactly the same of this command : /bin/date +%s -d 20070103 best regards -- David Touzeau -- Linux Ubuntu Dapper 6.0.6 FreePascal-Lazarus,perl,delphi,php icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] [fpstat - file]: Return the correct number of st_mode in order to get chmod permissions ?
Dear I need to return the correct mask of chmod permission, in this case, i have copy the FPC example , but i cannot convert info.st_mode in human readable mask (0777, 0755...) For example, with a file in 0755 mask the function return 16877 value in info.st_mode. best regards unit base_unix; {$mode objfpc}{$H+} interface uses Classes, SysUtils,variants, Linux,BaseUnix,IniFiles,strutils; type Tunix=class private public procedure Free; constructor Create; function get_file_permission(path:string):string; END; implementation constructor Tunix.Create; begin end; //## procedure Tunix.Free; begin end; function Tunix.get_file_permission(path:string):string; var s:string; info : stat; i:Integer; begin fpstat (path,info); writeln; writeln ('Result of fstat on file'); writeln ('Inode : ',info.st_ino); writeln ('Mode: ',info.st_mode); writeln ('nlink : ',info.st_nlink); writeln ('uid : ',info.st_uid); writeln ('gid : ',info.st_gid); writeln ('rdev: ',info.st_rdev); writeln ('Size: ',info.st_size); writeln ('Blksize : ',info.st_blksize); writeln ('Blocks : ',info.st_blocks); writeln ('atime : ',info.st_atime); writeln ('mtime : ',info.st_mtime); writeln ('ctime : ',info.st_ctime); end; //## end. -- David Touzeau -- Linux Ubuntu Dapper 6.0.6 FreePascal-Lazarus,perl,delphi,php icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] [oldlinux]: STAT_IRWXG get chmod number
hello Is there anybody has worked with STAT_IRWXG ? http://www.freepascal.org/docs-html/rtl/oldlinux/index-2.html I need infos in order to get a function that get file permissions on linux system (like 0777, 0755...) best regards -- David Touzeau -- Linux Ubuntu Dapper 6.0.6 FreePascal-Lazarus,perl,delphi,php icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] [oldlinux]: STAT_IRWXG get chmod number
Thanks marco for the way i have copy the example , but how can i convert info.st_mode in human readable mask (0777, 0755...) For example, a file in 0755 mask is 16877 value in info.st_mode. best regards unit base_unix; {$mode objfpc}{$H+} interface uses Classes, SysUtils,variants, Linux,BaseUnix,IniFiles,strutils; type Tunix=class private public procedure Free; constructor Create; function get_file_permission(path:string):string; END; implementation constructor Tunix.Create; begin end; //## procedure Tunix.Free; begin end; function Tunix.get_file_permission(path:string):string; var s:string; info : stat; i:Integer; begin fpstat (path,info); writeln; writeln ('Result of fstat on file'); writeln ('Inode : ',info.st_ino); writeln ('Mode: ',info.st_mode); writeln ('nlink : ',info.st_nlink); writeln ('uid : ',info.st_uid); writeln ('gid : ',info.st_gid); writeln ('rdev: ',info.st_rdev); writeln ('Size: ',info.st_size); writeln ('Blksize : ',info.st_blksize); writeln ('Blocks : ',info.st_blocks); writeln ('atime : ',info.st_atime); writeln ('mtime : ',info.st_mtime); writeln ('ctime : ',info.st_ctime); end; //## end. Marco van de Voort a écrit : Is there anybody has worked with STAT_IRWXG ? http://www.freepascal.org/docs-html/rtl/oldlinux/index-2.html That is a legacy api. Better use Baseunix: I need infos in order to get a function that get file permissions on linux system (like 0777, 0755...) http://www.freepascal.org/docs-html/rtl/baseunix/fpaccess.html or via stat: http://www.freepascal.org/docs-html/rtl/baseunix/fpstat.html Note that you can make octal values using the notation. E.g. var i : integer; begin i:=770; writeln(i); end. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- David Touzeau -- Linux Ubuntu Dapper 6.0.6 FreePascal-Lazarus,perl,delphi,php icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] [HTTPS]: Looking for a ssl http client
Yes The problem is fixed now by adding libssl.so.0 link Lukas Gebauer a écrit : Currently synpase doesn't working with ssl mode but if you want to do this in linux environement LibCurl is a good way and do that you want... http://curl.haxx.se/libcurl/pascal/ The only problem that it require *.so curl files to provide into your applications.. So i want to find the problem with synapse in SSL mode in order to not install others librairies... Synapse DOES working with SSL, you just must have corretly installed OpenSSL (or other supoorted SSL library), of course. ;-) As I see in synalist, your problem is solved now, right? -- David Touzeau -- Linux Ubuntu Dapper 6.0.6 FreePascal-Lazarus,perl,delphi,php icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] [HTTPS]: Looking for a ssl http client
Currently synpase doesn't working with ssl mode but if you want to do this in linux environement LibCurl is a good way and do that you want... http://curl.haxx.se/libcurl/pascal/ The only problem that it require *.so curl files to provide into your applications.. So i want to find the problem with synapse in SSL mode in order to not install others librairies... Rainer Stratmann a écrit : Am Samstag, 25. November 2006 04:09 schrieb TOUZEAU DAVID: Dear I'm searching examples that help me to implement on a linux system an HTTP client that supporting SSL HTTPS in order to post, get and downloading files with or without proxy support... A kind of functions in the same way of synalist THTTPSend (http://www.ararat.cz/synapse/docs/help/index.html) Is there anybody that have already found this requirements ?? Best regards Hello, I'm searching also for internet access and Networking with unit sockets. For me it is relative new with Linux. Does that mean that you are searching for normal down and uploading files to and from the internet? Kind regards Rainer -- David Touzeau -- Linux Ubuntu Dapper 6.0.6 FreePascal-Lazarus,perl,delphi,php icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] [SYSTEM] Linux defunct processes when execute external program SIGCHILD,fpWaitPID
Many thanks but how to implement this kind of procedure SIGCHILD on the child process. i have only these informations about ?? http://community.freepascal.org:1/docs-html/rtl/baseunix/sigchld.html If i understant the process must wait until the child process send Kill ? But how to receive the pid form the child process ? if i understand the function could be ??: ### Execl(commandline); fpWaitPid(??,0,WNOHANG); ### Best rgeardes Michael Van Canneyt a écrit : On Tue, 21 Nov 2006, TOUZEAU DAVID wrote: Dear my application run has a daemon When the daemon load, it create a Timer function as a class(TThread). This Timer thread has a loop and create an another Thread (called SendStatus each 5 minutes) function that load thread : ### procedure mTimer.Execute; var Pool:integer; xPool:longint; Myini:TIniFile; thread:SendStatus; begin while not Terminated do begin FConfigFilePath:='/etc/artica/artica-agent.conf'; LoadSettings; xPool:=(Fpool*60)*1000; logs('mTimer.Execute-initilize pooling for ' + IntTostr(Fpool) + ' milliseconds for each loop- '+ IntTostr(Fpool) + ' minutes (from ' + FConfigFilePath + ')'); LoadSettings; logs('mTimer.Execute-initilize Thread Sendstatus'); thread:=SendStatus.Create; //Creating the new thread thread.Resume;//Executing the new thread thread.free;//Terminate the new thread logs('mTimer.Execute-kill Thread Sendstatus'); if FMustReload=1 then begin Myini:=TIniFile.Create(FConfigFilePath); Myini.WriteInteger('ACTIONS','ReloadSettings',1); LoadSettings; xPool:=(Fpool*60)*1000; logs('mTimer.Execute-Reload settings - initilize pooling for ' + IntTostr(xPool) + ' milliseconds for each loop'); MyIni.free; end; Sleep(xPool); end; end; ### The SendStatus execute sometimes an external program writen in fpc called articacrypt. the function just use Execl to execute external program ### procedure SendStatus.DeCryptFile(Frompath:string;ToPath:string;PassPharse:string;SETT:KLNetSettings); var passphrase,commandline,Fbin_path:string; begin Fbin_path:=SETT.binaries_path; if Length(SETT.artica_crypt_key)=0 then begin SETT.logs('SendStatus.artica_crypt_key - null aborting..'); exit; end; commandline:=Fbin_path + '/articacrypt false ' + Frompath + ' ' + ToPath + ' ' + PassPharse; Execl(commandline); SETT.logs('SendStatus.DeCryptFile - ' + ToPath + ' was process'); exit; end; ### this external program kill itself by calling halt() function at the end of the code. My problem is that each execution of this program will add defunc in the Linux system : example of ps -aux : root 25992 0.0 0.1 20500 2292 pts/0Sl 19:45 0:00 /opt/artica/bin/articaagentd root 26008 0.0 0.0 0 0 pts/0Z19:45 0:00 [articacrypt] defunct root 26009 0.0 0.0 0 0 pts/0Z19:45 0:00 [articacrypt] defunct root 26010 0.0 0.0 0 0 pts/0Z19:45 0:00 [articacrypt] defunct root 26011 0.0 0.0 0 0 pts/0Z19:45 0:00 [articacrypt] defunct root 26012 0.0 0.0 0 0 pts/0Z19:45 0:00 [articacrypt] defunct root 26134 0.0 0.0 0 0 pts/0Z19:47 0:00 [articacrypt] defunct root 26135 0.0 0.0 0 0 pts/0Z19:47 0:00 [articacrypt] defunct root 26136 0.0 0.0 0 0 pts/0Z19:47 0:00 [articacrypt] defunct root 26137 0.0 0.0 0 0 pts/0Z19:47 0:00 [articacrypt] defunct root 26138 0.0 0.0 0 0 pts/0Z19:47 0:00 [articacrypt] defunct root 26247 0.0 0.0 0 0 pts/0Z19:49 0:00 [articacrypt] defunct root 26248 0.0 0.0 0 0 pts/0Z19:49 0:00 [articacrypt] defunct root 26249 0.0 0.0 0 0 pts/0Z19:49 0:00 [articacrypt] defunct root 26250 0.0 0.0 0 0 pts/0Z19:49 0:00 [articacrypt] defunct root 26251 0.0 0.0 0 0 pts/0Z19:49 0:00 [articacrypt] defunct root 26388 0.0 0.0 0 0 pts/0Z19:51 0:00 [articacrypt] defunct root 26389 0.0 0.0 0 0 pts/0Z19:51 0:00 [articacrypt] defunct root 26390 0.0 0.0 0 0 pts/0Z19:51 0:00 [articacrypt] defunct root 26391 0.0 0.0 0 0 pts/0Z19:51 0:00 [articacrypt] defunct root 26392 0.0 0.0 0 0 pts/0Z19:51 0:00 [articacrypt] defunct root 26511 0.0 0.0 0 0 pts/0Z19:53 0:00 [articacrypt] defunct root 26512 0.0 0.0 0 0 pts/0Z
Re: [fpc-pascal] [SYSTEM]: How detecting if run as root ?
Many thanks i found the function GetEUID i'll try it http://www.cs.uwc.ac.za/~firstyear/manuals/doc/units/unitsse36.html#x53-41900012.3 Pete Cervasio a écrit : On Wednesday 11 October 2006 20:44, Michalis Kamburelis wrote: Pete Cervasio wrote: The better way would be to use the geteuid function in the libc unit, It would be even better to use FpGetEUid function from the BaseUnix unit. See [http://www.freepascal.org/docs-html/rtl/baseunix/fpgeteuid.html]. DOH! Thanks for reminding me, Michalis. I always forget about seeing if a function is already in the RTL when doing things that I know are standard C library functions. Force of habit is my (bad) excuse. :) Best regards, Pete C. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- David Touzeau -- Linux Ubuntu Dapper 6.0.6 FreePascal-Lazarus,perl,delphi,php icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] [NETWORK - LINUX ]: Calculate broadcast - network
message /message Dear I develop a tool that change the network settings in /etc/network/interfaces the config file must be iface eth0 inet static address 192.168.xx.xx netmask 255.255.255.0 network 192.168.xx.0 broadcast 192.168.xx.255 gateway 192.168.xx.xx In this case when user type 10.1.1.2 and 255.255.0.0 i need to calculate the network address and broadcast. Where can i found a function that return the good answer ? Is there somebody has developped a such function ? -- David Touzeau -- Linux Ubuntu Dapper 6.0.6 FreePascal-Lazarus,perl,delphi,php icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] [NETWORK - LINUX ]: Calculate broadcast - network
message /message Dear The tool is designed to simplify the change network settings quickly. So the goal for the admin is to type: #./tool 192.168.1.2 255.255.255.0 192.168.1.1 and the tool will change settings in /etc/network/interfaces by iface eth0 inet static address 192.168.1.2 netmask 255.255.255.0 network 192.168.xx.0 broadcast 192.168.xx.255 gateway 192.168.1.1 And set /etc/ini.d/networking reload. Just need this. best regards -- David Touzeau -- Linux Ubuntu Dapper 6.0.6 FreePascal-Lazarus,perl,delphi,php icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] [CRYPT]: Is there an unit to perform crypt/decrypt on Linux ?
Dear I would like to crypt some files/strings/datas with fpc on Linux systems. What unit can i use to provide this feature ? I there a standard unit or somebody had already developped a such unit ? -- David Touzeau -- Linux Ubuntu Dapper 6.0.6 FreePascal-Lazarus,perl,delphi,php icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] [CRYPT]: Is there an unit to perform crypt/decrypt on Linux ?
Many Thanks vincent exactly what i want to find !!! Vincent Snijders a écrit : TOUZEAU DAVID schreef: Dear I would like to crypt some files/strings/datas with fpc on Linux systems. What unit can i use to provide this feature ? I there a standard unit or somebody had already developped a such unit ? Maybe you can use this: http://wiki.lazarus.freepascal.org/DCPcrypt Vincent -- David Touzeau -- Linux Ubuntu Dapper 6.0.6 FreePascal-Lazarus,perl,delphi,php icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] [SYSTEM]: How detecting if run as root ?
Dear I need to detect if the program is executed as root privileges on Linux system. Did somebody had developped a such function ?? Best regards. -- David Touzeau -- Linux Ubuntu Dapper 6.0.6 FreePascal-Lazarus,perl,delphi,php icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] RE: Get Local IP using glib (eth0,eth1)
Many Thanks Jeff and Micha. This function works perfectly without need to regex ifconfig... And i use glibc I develop only on linux system. Great respects... Just another question... (this because i came from Windows OS) how can i list wich interface loaded without need to parse /etc/networks/...? (wlan0,wlan1,eth0,eth1...) Best regards... Jeff Pohlmeyer a écrit : I'm trying to write a function to read the local IP eth0/eth1 using glibc library... program ip_addr; {$MODE OBJFPC} uses libc; const IP_NAMESIZE = 16; type ipstr = array[0..IP_NAMESIZE-1] of char; function GetIPAddressOfInterface( if_name:ansistring):ansistring; var ifr : ifreq; tmp:ipstr; sock : longint; p:pChar; begin Result:='0.0.0.0'; strncpy( ifr.ifr_ifrn.ifrn_name, pChar(if_name), IF_NAMESIZE-1 ); ifr.ifr_ifru.ifru_addr.sa_family := AF_INET; FillChar(tmp[0], IP_NAMESIZE, #0); sock := socket(AF_INET, SOCK_DGRAM, IPPROTO_IP); if ( sock = 0 ) then begin if ( ioctl( sock, SIOCGIFADDR, @ifr ) = 0 ) then begin p:=inet_ntoa( ifr.ifr_ifru.ifru_addr.sin_addr ); if ( p nil ) then strncpy(tmp, p, IP_NAMESIZE-1); if ( tmp[0] #0 ) then Result := tmp; end; libc.__close(sock); end; end; begin if (ParamCount=1) then WriteLn(GetIPAddressOfInterface(ParamStr(1))) else WriteLn('Usage:', ParamStr(0), 'interface-name') end. - Jeff ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- David Touzeau -- Linux Ubuntu Dapper 6.0.6 FreePascal-Lazarus,perl,delphi,php icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] [libtar.pas]:Error: Illegal type conversion: ShortString to ^Char without compilator options
Dear I would like to use some units developped from delphi/klyx with Lazarus IDE On Linux. It seems that there is some differences between delphi/freepascal especially for longstring conversion. Many times, i received this compilator error : For example by using the LibTar.pas (http://www.destructor.de/libtar/index.htm) libtar.pas(355,8) Error: Illegal type conversion: ShortString to ^Char i fixed this error with {$H+}{$LongString On} tokens But is it this good way ??? is there an another solution ?? Best regards. -- David Touzeau -- Linux Ubuntu Dapper 6.0.6 FreePascal-Lazarus,perl,delphi,php icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] [libtar.pas]:Error: Illegal type conversion: ShortString to ^Char without compilator options
Many thanks Vincent the {$mode delphi} is a good way... Vincent Snijders a écrit : TOUZEAU DAVID schreef: Dear I would like to use some units developped from delphi/klyx with Lazarus IDE On Linux. It seems that there is some differences between delphi/freepascal especially for longstring conversion. Many times, i received this compilator error : For example by using the LibTar.pas (http://www.destructor.de/libtar/index.htm) libtar.pas(355,8) Error: Illegal type conversion: ShortString to ^Char i fixed this error with {$H+}{$LongString On} tokens But is it this good way ??? is there an another solution ?? An alternative is to add {$mode delphi} to the source file or compile with -Sd compiler option. Vincent -- David Touzeau -- Linux Ubuntu Dapper 6.0.6 FreePascal-Lazarus,perl,delphi,php icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] RE: Get Local IP using glib (eth0,eth1)
Many Thanks for this way jeff... /proc/net/dev is more compatible Impressed it for your information. My program will run only on linux system... Marco van de Voort a écrit : I would parse /proc/net/dev instead Better, but still Linux only. For a good solution, a resolver unit that accesses libc should be written that is portable (unlike the libc unit) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- David Touzeau -- Linux Ubuntu Dapper 6.0.6 FreePascal-Lazarus,perl,delphi,php icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] RE: Get Local IP using glib (eth0,eth1)
Many thanks to the community To reply to Graeme : why not just use the /sbin/ifconfig output ? Simply to be more dev compliance... using an external program is slower and sometime ifconfig doesn't exist or is deleted on target computers. To reply to Marco : And the only good solution is a portable resolver unit? How will you resolve eth0 on Win32 or BSD ? For WIN32, i d'ont care because the program is only for Linux systems. Your are true, in BSD the network interface is not the same and i must detect wich interface is used... Best regards Graeme Geldenhuys a écrit : I have these two functions in my .bashrc file. You only need to run ii for the cool output. Now back to the question - If it is for linux only, why not just use the /sbin/ifconfig output. After all, it is accurate and seem much easier than all those libc/library methods. I pull the IPs and Interfaces available from the /sbin/ifconfig output and works just fine. If it was needed on windows, I am sure you could to the same thing with the 'ipconfig' output. My 2c worth! :-) Regards, - Graeme - .bashrc - function my_ip() # get IP adresses { MY_IP=$(/sbin/ifconfig eth0 | awk '/inet/ { print $2 } ' | sed -e s/addr://) MY_ISP=$(/sbin/ifconfig ppp0 | awk '/P-t-P/ { print $3 } ' | sed -e s/P-t-P://) } function ii() # get current host related info { echo -e \nYou are logged on ${RED}$HOST echo -e \nAdditionnal information:$NC ; uname -a echo -e \n${RED}Users logged on:$NC ; w -h echo -e \n${RED}Current date :$NC ; date echo -e \n${RED}Machine stats :$NC ; uptime echo -e \n${RED}Memory stats :$NC ; free my_ip 2- ; echo -e \n${RED}Local IP Address :$NC ; echo ${MY_IP:-Not connected} echo -e \n${RED}ISP Address :$NC ; echo ${MY_ISP:-Not connected} echo } - On 06/10/06, Jeff Pohlmeyer [EMAIL PROTECTED] wrote: Better, but still Linux only. For a good solution, a resolver unit that accesses libc should be written that is portable (unlike the libc unit) If I understood correctly, the OP had two questions: 1. Retrieve a list of interface names on a *linux* system. 2. Return the IP address for a given *linux* interface name. And the only good solution is a portable resolver unit? How will you resolve eth0 on Win32 or BSD ? -Jeff -- David Touzeau -- Linux Ubuntu Dapper 6.0.6 FreePascal-Lazarus,perl,delphi,php icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] visualserver from VisualSynapse how implement it as a Linux console Daemon
Dear is anybody there use visualserver from VisualSynapse (http://visualsynapse.sourceforge.net/?id=8) and impleted it on Linux has a console mode...?? Examples given is only on application interface ... Problems: 1) When the application start, no web page are generated... 2) i would like to develop a variant of this web server. In this case, i need to trap the requests received by the process. Here it is a sample that didn't working //* program shttpserver; {$mode objfpc}{$H+} uses //ArticaAgent cthreads,custapp, Classes, SysUtils, fpcunit,httpserver ; const Version = 'Version 0.1'; type TTestRunner = class(TCustomApplication) private protected procedure DoRun; override; public procedure Listen(receive:string); end; procedure TTestRunner.DoRun; var I: integer; S: string; begin // writeln('create...'); end; procedure TTestRunner.Listen(receive:string); begin // writeln('string received: ' + receive); end; var App: TTestRunner; eHTTP : TvsHTTPServer; begin App := TTestRunner.Create(nil); eHTTP := TvsHTTPServer.Create(nil); eHTTP.LogFile := 'httplog.log'; eHTTP.ServerName := 'Visual Synapse Demo HTTP Server'; eHTTP.ListenPort := '8000'; eHTTP.SSL := False; eHTTP.ListenIP := '0.0.0.0'; //any eHTTP.RegisterDir ('/home/touzeau/Desktop/visualserverdemo/web', '/'); eHTTP.RegisterDefaultDoc('index.htm'); eHTTP.Active := True; // eHTTP.OnGet := @App.Listen; //not working it seems that here i can receive requests from clients. App.Initialize; App.Title := 'Console www.'; App.Run; App.Free; end. //* -- David Touzeau -- Linux Ubuntu Dapper 6.0.6 FreePascal-Lazarus,perl,delphi,php icq:160018849 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Get Local IP using glib (eth0,eth1)
Hi I'm trying to write a function to read the local IP eth0/eth1... using glibc library... I found only examples that found the 127.0.0.1 IP but not the real IP : http://community.freepascal.org:1/bboards/message?message_id=233776forum_id=24083 http://lists.freepascal.org/lists/fpc-pascal/2002-March/002932.html Is someone could help me to find the solution... Currently i use regex on ifconfig that is a hack! best regards -- ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal