Re: Argument passing between perl and C function.
On 6/2/05, J aperlh wrote: Argument passing between perl and a C function. [...snip...] my $ret = $app-Calculate($names, $values, 3); You don't pass arguments directly from Perl to C. You use an XS or Inline interface, either your own or supplied by a module. The argument passing should be documented in the interfacing code. In your case I see you are using the Win32::OLE module, but I don't see a method called Calculate in the documentation (http://search.cpan.org/dist/Win32-OLE/lib/Win32/OLE.pm). I also see that Calculate is a method called by $app, but $app is not defined anywhere. Without knowning the type of object $app is, I have no way of looking at how Calculate is called. If you have a module you are using that $app is an object of, look-up the documentation for that module, the API to call Calculate should be explained there. If you don't understand the module documentation please post a link to it. At least post enough code to understand what $app is. Regards, -- Offer Kaye ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Argument passing between perl and C function.
J aperlh wrote: Argument passing between perl and a C function. There is C function in a OLE server: What kind of variable should I pass to this function? # BOOL Calculate(BSTR* names, double* values, short number_of_names); I tried the following script, but there is always an error like Type mismatch ... Is there any simple way to pass argument between perl and C function? Not sure why you're using OLE for this. Win32_API might be more what you're looking for to interface to a C DLL. # #! perl -W use strict; use Win32::OLE; use Win32::OLE::Variant; my $names = Variant(VT_BSTR|VT_ARRAY, 3); my $values = Variant(VT_R8|VT_ARRAY, 3); $names-Put(['name1', 'name2', 'name3']); $values-Put([0, 0, 0]); my $ret = $app-Calculate($names, $values, 3); -- ,-/- __ _ _ $Bill LuebkertMailto:[EMAIL PROTECTED] (_/ / )// // DBE CollectiblesMailto:[EMAIL PROTECTED] / ) /-- o // // Castle of Medieval Myth Magic http://www.todbe.com/ -/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff) ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: parsing event logs in win2000
i need to parse system event logs for win2000 Professional and i can see what i'm looking for when i use the viewer; i can also save the log in text format from the viewer. Is there any way i could programmatically get an *.evt file in a given path AND SAVE IT IN TEXT FORMAT, and then open and parse? Two nice easy ways to do this in perl are the Win32::Eventlog module, or the WMI class Win32_NTLogEvent. The latter is particularly useful if you want to search large logs for specific IDs, or connect to remote machines, since the ability to issue a specific query confers quite a speed increase over Win32::Eventlog. Docs here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/ wmi/win32_ntlogevent.asp Try something like this to get you started (cobbled from other code, not tested): my $x = Win32::OLE-GetObject(WinMgmts://$ENV{COMPUTERNAME}/root/cimv2) or die Can't instantiate WMI; my $SQL = qq( SELECT * FROM Win32_NTLogEvent WHERE Logfile='System' AND EventCode='1074' ); my $y = $x-ExecQuery($SQL) or die WMI query failed; foreach my $event (in $y) { my $message = $event-{Message}; $message =~ s|(\xd\xa){2}|\n|g; print $message\n; } Good luck! Paul * Gloucester Research Limited believes the information provided herein is reliable. While every care has been taken to ensure accuracy, the information is furnished to the recipients with no warranty as to the completeness and accuracy of its contents and on condition that any errors or omissions shall not be made the basis for any claim, demand or cause for action. * ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Net::Telnet
John wrote: its does not work on these servers: Windows 2000 Pro, Windows XP pro, Windows 2000 server pro, Windows server 2003. Reason is, the new windows server uses ANSI codes and you CAN'T turn them off like on a UNIX box. These ANSI codes garble up the responses to Net::Telnet. I'd put it this way: The telnet server in these versions of Windows is broken. It doesn't follow the RFCs. To make telnet work, use an alternate telnet server, e.g. http://kpym.sourceforge.net/ -- Mark ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Net::Telnet
I have had no issues using Net::Telnet on XP Pro that are using the MS Windows telnet server. Stating that it does not work on Windows server/workstations is not entirely true. Try starting the MS Windows telnet server, and using it. - Aaron -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Thomas, Mark - BLS CTR Sent: Thursday, June 02, 2005 7:35 AM To: 'John Serink'; Rajesh Vattem; perl-win32-users@listserv.ActiveState.com Subject: RE: Net::Telnet John wrote: its does not work on these servers: Windows 2000 Pro, Windows XP pro, Windows 2000 server pro, Windows server 2003. Reason is, the new windows server uses ANSI codes and you CAN'T turn them off like on a UNIX box. These ANSI codes garble up the responses to Net::Telnet. I'd put it this way: The telnet server in these versions of Windows is broken. It doesn't follow the RFCs. To make telnet work, use an alternate telnet server, e.g. http://kpym.sourceforge.net/ -- Mark ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
TK Question
I've been able to finally get TK:Statusbar to work, but still not sure how to get rid of the buttons. I would like this to automatically launch the Start subroutine w/o pressing a button to do it. Anyone have experience with TK in bypassing the need for human interaction? I would Post this to the TK group, but there doesn't seem to be anyway to subscribe to it. Thanks in advance. use Tk; use Tk::ProgressBar; use strict; use Warnings; my $percent_done = 0; my @colors = ( Omitted on purpose ) my $mw = MainWindow-new; my $text = Percentage to date: $percent_done; $mw-title('Progress Bar'); my $message = $mw-Message(-textvariable = \$text, -width = 130,-border = 2); my $progress = $mw-ProgressBar(-width = 20,-length = 400, -from = 0, -to = 100, -gap=0, -anchor = 'w',-blocks = 20,-troughcolor='white',-colors=[EMAIL PROTECTED], -variable = \$percent_done); my $exit = $mw-Button(-text = 'Exit', -command = [$mw = 'destroy']); my $get = $mw-Button(-text = 'Press to start!', -command = \start); $get-pack; $progress-pack; $message-pack; $exit-pack; MainLoop; sub start { My Program goes here.. $mw-update; } __ Discover Yahoo! Stay in touch with email, IM, photo sharing and more. Check it out! http://discover.yahoo.com/stayintouch.html ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Reg Exp - Extracting html files
I can get the similar to work, but the problem is when there is more than one file, it only returns the last one. Example: my $x = link one http://blah.com/dfs/fdsf/fdsfd/dfdsf/test.jar link two http://blah.com/dfs/fdsf/fdsfd/dfdsf/test2.jar;; (my $filename = $x) =~ s/^.*[\\\/]//; print $filename; Obviously this returns test2.jar. How can I have this return all of them, there could be one file there could be multilpe? Thank you, Steve From: $Bill Luebkert [EMAIL PROTECTED] To: steve silvers [EMAIL PROTECTED] CC: perl-win32-users@listserv.ActiveState.com Subject: Re: Reg Exp - Extracting html files Date: Wed, 01 Jun 2005 16:33:52 -0700 steve silvers wrote: I'm searching many big text columns in my database and I need to extract just the html file names. So far I'm working with directories and file names. So it needs to grab the file names from examples like. directory/file2.html dir/dir2/testfile.htm and list file2.html testfile.htm You can use File::Basename or I usually just opt for a RE: (my $filename = $path) =~ s/^.*[\\\/]//; # get just the filename portion of path -- ,-/- __ _ _ $Bill LuebkertMailto:[EMAIL PROTECTED] (_/ / )// // DBE CollectiblesMailto:[EMAIL PROTECTED] / ) /-- o // // Castle of Medieval Myth Magic http://www.todbe.com/ -/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff) ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Packing variable or unknown structure
hello I am starting to learn how to import functions using Win32::API the following function outputs a pointer to a structure and I understand how to use perls pack to build the required structure. WINSETUPAPI BOOL WINAPI SetupDiEnumDeviceInfo( IN HDEVINFO DeviceInfoSet, IN DWORD MemberIndex, OUT PSP_DEVINFO_DATA DeviceInfoData ); typedef struct _SP_DEVINFO_DATA { DWORD cbSize; GUID ClassGuid; DWORD DevInst; ULONG_PTR Reserved; } SP_DEVINFO_DATA, *PSP_DEVINFO_DATA; SP_DEVINFO_DATA is represented as $devdata = pack ( 'LL4LL', 28, 0, 0, 0 ); then setupdienumdeviceinfo can be called as SetupDiEnumDeviceInfo( $devicedev, $index, $devdata ); my question is this; what if the structure is unknown? how can I prepare a packed scalar of unknown size or of variable size? BOOLEAN HidD_GetPreparsedData( IN HANDLE HidDeviceObject, OUT PHIDP_PREPARSED_DATA *PreparsedData ); looking at MSDN online we get the following The internal structure of a _HIDP_PREPARSED_DATA structure is reserved for internal system use ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Reg Exp - Extracting html files
@urls = $x =~ m#(http://[^ ]+)#g; foreach $url (@urls) { $file = $url =~ m#/([^/]+)$# and print $file } At 01:44 PM 6/2/05 +, steve silvers wrote: my $x = link one http://blah.com/dfs/fdsf/fdsfd/dfdsf/test.jar link two http://blah.com/dfs/fdsf/fdsfd/dfdsf/test2.jar;; (my $filename = $x) =~ s/^.*[\\\/]//; print $filename; Obviously this returns test2.jar. How can I have this return all of them, there could be one file there could be multilpe? -- REMEMBER THE WORLD TRADE CENTER ---= WTC 911 =-- ...ne cede males 0100 ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Reg Exp - Extracting html files
steve silvers wrote: I can get the similar to work, but the problem is when there is more than one file, it only returns the last one. Example: my $x = link one http://blah.com/dfs/fdsf/fdsfd/dfdsf/test.jar link two http://blah.com/dfs/fdsf/fdsfd/dfdsf/test2.jar;; (my $filename = $x) =~ s/^.*[\\\/]//; print $filename; Obviously this returns test2.jar. How can I have this return all of them, there could be one file there could be multilpe? Now you're changing the problem on us from your last post. You could try something more rigorous: use strict; use warnings; use URI; use URI::Escape; my @x = ( link one http://blah.com/dfs/fdsf/fdsfd/dfdsf/test.jar link two http://blah.com/dfs/fdsf/fdsfd/dfdsf/test2.jar;, link one http://blah.com/dfs/fdsf/fdsfd/dfdsf/test.jar?foo=bar link two http://blah.com/dfs/fdsf/fdsfd/dfdsf/test%202.jar;, ); foreach my $line (@x) { # split on http: (URLs) foreach (split /(http:[^\s]+)/, $line) { next if not /^http:/i; # skip non-URLs my $uri = URI-new($_); # get a URL obj my $path = $uri-path; # get path portion $path = uri_unescape ($path); # unescape the escaped stuff $path =~ s/^.*[\\\/]//; # now drop the path and leave filename print $path\n; } } __END__ steve silvers wrote: I'm searching many big text columns in my database and I need to extract just the html file names. So far I'm working with directories and file names. So it needs to grab the file names from examples like. directory/file2.html dir/dir2/testfile.htm and list file2.html testfile.htm -- ,-/- __ _ _ $Bill LuebkertMailto:[EMAIL PROTECTED] (_/ / )// // DBE CollectiblesMailto:[EMAIL PROTECTED] / ) /-- o // // Castle of Medieval Myth Magic http://www.todbe.com/ -/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff) ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
SAS datasets
Does anyone know how to read SAS datasets with perl? (.sas7bdat) I am trying to get information from these datasets without having to launch SAS. Any ideas? Thanks in advance, Jim. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: SAS datasets
James Deeke [EMAIL PROTECTED] wrote: Does anyone know how to read SAS datasets with perl? (.sas7bdat) I am trying to get information from these datasets without having to launch SAS. The .sas7bdat data structure is the SAS standard for versions 7.0 and following. (They're now up to SAS 9.1.3 and aiming at 9.2 .) It's proprietary. And, as far as I know, there's no DBI interface written to connect SAS databases with Perl. If you don't want to use SAS to open the file, you'll need to obtain something like DBMS/Copy which can read SAS datasets and translate them into something more helpful. You can run DBMS/Copy from the command line, so you can use system() to do the translation before reading the translated file. You can also use SAS to pump the file straight into a .csv format, or tab-delimited, or even (heaven forbid) an Excel spreadsheet, just by using PROC EXPORT in a quickie SAS program that you could run using Perl. HTH, David -- David Cassell, CSC [EMAIL PROTECTED] Senior computing specialist mathematical statistician ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Packing variable or unknown structure
cafs wrote: hello I am starting to learn how to import functions using Win32::API the following function outputs a pointer to a structure and I understand how to use perls pack to build the required structure. WINSETUPAPI BOOL WINAPI SetupDiEnumDeviceInfo( IN HDEVINFO DeviceInfoSet, IN DWORD MemberIndex, OUT PSP_DEVINFO_DATA DeviceInfoData ); typedef struct _SP_DEVINFO_DATA { DWORD cbSize; GUID ClassGuid; DWORD DevInst; ULONG_PTR Reserved; } SP_DEVINFO_DATA, *PSP_DEVINFO_DATA; SP_DEVINFO_DATA is represented as $devdata = pack ( 'LL4LL', 28, 0, 0, 0 ); then setupdienumdeviceinfo can be called as SetupDiEnumDeviceInfo( $devicedev, $index, $devdata ); my question is this; what if the structure is unknown? how can I prepare a packed scalar of unknown size or of variable size? I would just create an array of unsigned bytes of max size and use that. $devdata = pack 'U512', 0 x 512;# where 512 is arbitrary BOOLEAN HidD_GetPreparsedData( IN HANDLE HidDeviceObject, OUT PHIDP_PREPARSED_DATA *PreparsedData ); looking at MSDN online we get the following The internal structure of a _HIDP_PREPARSED_DATA structure is reserved for internal system use -- ,-/- __ _ _ $Bill LuebkertMailto:[EMAIL PROTECTED] (_/ / )// // DBE CollectiblesMailto:[EMAIL PROTECTED] / ) /-- o // // Castle of Medieval Myth Magic http://www.todbe.com/ -/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff) ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Argument passing between perl and C function.
Thanks for you guys help. There is an application written in C language by my colleague. We are not allowed to share this application for security reason. What I am going to do is to call a set of functions in this application (OLE server) from a PERL script (OLE controller). So far, all the functions are works well, except a reference(pointer) related functions: --- BOOL Calculate(BSTR* names, double* values, short number_of_names); I don't know that I should pass to this funtion. Array reference or something else? I know that if the OLE controller is in C language, things will be easier, Passing the first element of the array to this function is ok. On 6/2/05, Offer Kaye [EMAIL PROTECTED] wrote: On 6/2/05, J aperlh wrote: Argument passing between perl and a C function. [...snip...] my $ret = $app-Calculate($names, $values, 3); You don't pass arguments directly from Perl to C. You use an XS or Inline interface, either your own or supplied by a module. The argument passing should be documented in the interfacing code. In your case I see you are using the Win32::OLE module, but I don't see a method called Calculate in the documentation (http://search.cpan.org/dist/Win32-OLE/lib/Win32/OLE.pm). I also see that Calculate is a method called by $app, but $app is not defined anywhere. Without knowning the type of object $app is, I have no way of looking at how Calculate is called. If you have a module you are using that $app is an object of, look-up the documentation for that module, the API to call Calculate should be explained there. If you don't understand the module documentation please post a link to it. At least post enough code to understand what $app is. Regards, -- Offer Kaye ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Net::Telnet
Correct. -Original Message- From: Thomas, Mark - BLS CTR [mailto:[EMAIL PROTECTED] Sent: Thursday, June 02, 2005 8:35 PM To: John Serink; Rajesh Vattem; perl-win32-users@listserv.ActiveState.com Subject: RE: Net::Telnet John wrote: its does not work on these servers: Windows 2000 Pro, Windows XP pro, Windows 2000 server pro, Windows server 2003. Reason is, the new windows server uses ANSI codes and you CAN'T turn them off like on a UNIX box. These ANSI codes garble up the responses to Net::Telnet. I'd put it this way: The telnet server in these versions of Windows is broken. It doesn't follow the RFCs. To make telnet work, use an alternate telnet server, e.g. http://kpym.sourceforge.net/ -- Mark ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Net::Telnet
I have heard the MS Telnet server was fixed on XP (and that would seem then on 2003) but have not tested it. I know Net::Telnet did NOT work on Win2K pro, I wasted about a week trying to get it to. Worked fine on NT 4.0 though. Cheers, John -Original Message- From: Aaron.Tesch [mailto:[EMAIL PROTECTED] Sent: Thursday, June 02, 2005 9:22 PM To: Thomas, Mark - BLS CTR; John Serink; Rajesh Vattem; perl-win32-users@listserv.ActiveState.com Subject: RE: Net::Telnet I have had no issues using Net::Telnet on XP Pro that are using the MS Windows telnet server. Stating that it does not work on Windows server/workstations is not entirely true. Try starting the MS Windows telnet server, and using it. - Aaron -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Thomas, Mark - BLS CTR Sent: Thursday, June 02, 2005 7:35 AM To: 'John Serink'; Rajesh Vattem; perl-win32-users@listserv.ActiveState.com Subject: RE: Net::Telnet John wrote: its does not work on these servers: Windows 2000 Pro, Windows XP pro, Windows 2000 server pro, Windows server 2003. Reason is, the new windows server uses ANSI codes and you CAN'T turn them off like on a UNIX box. These ANSI codes garble up the responses to Net::Telnet. I'd put it this way: The telnet server in these versions of Windows is broken. It doesn't follow the RFCs. To make telnet work, use an alternate telnet server, e.g. http://kpym.sourceforge.net/ -- Mark ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Argument passing between perl and C function.
--- Thanks for you guys help. There is an application written in C language by my colleague. We are not allowed to share this application for security reason. What I am going to do is to call a set of functions in this application (OLE server) from a PERL script (OLE controller). So far, all the functions are works well, except a reference(pointer) related functions: --- BOOL Calculate(BSTR* names, double* values, short number_of_names); names: a list of names values: a list of corresponding values, number_of_names: size of the array I don't know that I should pass to this funtion. Array reference or something else? I know that if the OLE controller is in C language, things will be easier, Passing the first element of the array to this function is ok On 6/2/05, $Bill Luebkert [EMAIL PROTECTED] wrote: J aperlh wrote: Argument passing between perl and a C function. There is C function in a OLE server: What kind of variable should I pass to this function? # BOOL Calculate(BSTR* names, double* values, short number_of_names); I tried the following script, but there is always an error like Type mismatch ... Is there any simple way to pass argument between perl and C function? Not sure why you're using OLE for this. Win32_API might be more what you're looking for to interface to a C DLL. # #! perl -W use strict; use Win32::OLE; use Win32::OLE::Variant; my $names = Variant(VT_BSTR|VT_ARRAY, 3); my $values = Variant(VT_R8|VT_ARRAY, 3); $names-Put(['name1', 'name2', 'name3']); $values-Put([0, 0, 0]); my $ret = $app-Calculate($names, $values, 3); -- ,-/- __ _ _ $Bill LuebkertMailto:[EMAIL PROTECTED] (_/ / )// // DBE CollectiblesMailto:[EMAIL PROTECTED] / ) /-- o // // Castle of Medieval Myth Magic http://www.todbe.com/ -/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff) ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Argument passing between perl and C function.
- Original Message - From: J aperlh [EMAIL PROTECTED] Is there any simple way to pass argument between perl and C function? If you have a C compiler, you could use the Inline::C module. Cheers, Rob ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Packing variable or unknown structure
$Bill Luebkert wrote: I would just create an array of unsigned bytes of max size and use that. $devdata = pack 'U512', 0 x 512; # where 512 is arbitrary Whoops - that unicode - should be: $devdata = pack 'C512', 0 x 512; -- ,-/- __ _ _ $Bill LuebkertMailto:[EMAIL PROTECTED] (_/ / )// // DBE CollectiblesMailto:[EMAIL PROTECTED] / ) /-- o // // Castle of Medieval Myth Magic http://www.todbe.com/ -/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff) ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs