Perl OS system equivalence or Perl scripts for UNIX-and-Windows

2006-05-25 Thread benbart
Hi all, I've inherited a bunch of scripts that am spending lots of time debugging and tracing, changing etc. Part of the task also is to have the same modified in some way so that I can use it for both UNIX and Windows. Lots of these scripts have system "" on them which of course I can't run on W

How to convert these tablespace output report into a delimited file, csv or tilde

2006-06-21 Thread BenBart
Hi all, Can anyone suggest what is the best way to convert the lines of text between the = into a delimited file? Do I have to read the lines one at a time and append the delimiter that I wanted into the end of each line and then re-direct the output to a file? FYI, the line "Tablesp

how to avoid "spawning" multiple process of the same script ..

2006-07-05 Thread BenBart
Hi all, How do I prevent multiple instance of the same script from running? That is for example, if I have a script named script1.pl and it is already running, I want the script to be able to check that it is already running and then just exit ... Is this possible to do in both UNIX and Wind

Perl's fork ... any example please ...

2006-07-05 Thread BenBart
Hi all, Am getting confused on how to use fork, does anyone have an example on how to use this or where and what is it used for ??? Not sure if this is what I needed Is fork the equivalent of running the UNIX wait command when writing a UNIX script where you want to make sure that

Perl's system "[OS_COMMAND]"

2006-07-05 Thread BenBart
Hi all, Is there another option of running an OS command or UNIX script besides using system "[OS_COMMAND]", for example system "cat /etc/hosts" or system "[UNIX_SCRIPT]"? How can I make sure that the system '[OS_COMMAND]" finishes its run before I proceed to run the rest of the codes in the

BASEDIR and BASENAME on Windows

2006-08-01 Thread BenBart
Hi all, Can anyone please tell me how to get the BASENAME and BASEDIR of a file ... i.e. for example, if I have C:\Windows\Temp\Dir1\MyFile.TXT, I want to be able to get the BASENAME which is MyFile and the BASEDIR which is C:\Windows\Temp\Dir1 and assign them to variables ... Thanks in adva

Dynamic variables - from INI files ...

2006-08-11 Thread benbart
Hi, I am writing a Perl script that reads some kind of INI file. I cannot use Config::INI or install any new modules due to some restriction so am reading the whole INI text file one line at a time and storing them into an array. Here are what on my INI files: FTP_USER=FTPUser FTP_PASSWORD=FTPUse

How to search/match a variable pattern

2006-08-11 Thread benbart
Hi all, Can some please advise how to get this to work? print "matches" if $string =~ m/$pattern/; Am trying to search for a pattern but the pattern has to be a variable. Thanks in advance. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: How to search/match a variable pattern

2006-08-11 Thread benbart
Hi John, Thanks for a very quick response John. It gives the error as below: Trailing \ in regex m/D:\STUDY\PERL\MYFTP\/ at D:\Study\Perl\MyFtp\Ftp1.pl line 109. ($base,$path,$type) = fileparse($ARGV[0]); $pattern=$path; print "matches" if $string =~ m/$pattern/; I print $pattern and it is

Re: How to search/match a variable pattern

2006-08-11 Thread benbart
Hi John, Thanks for a very quick response John. It gives the error as below: Trailing \ in regex m/D:\STUDY\PERL\MYFTP\/ at D:\Study\Perl\MyFtp\Ftp1.pl line 109. ($base,$path,$type) = fileparse($ARGV[0]); $pattern=$path; print "matches" if $string =~ m/$pattern/; I print $pattern and it is

Running system command or batch file using system "[command]"

2006-08-12 Thread benbart
Hi all, Using Perl on Windows, at the moment am running commands and batch files using system "[OS COMMAND]/[BATCH FILE]", can someone tell me how can I check for the success or failure of running the command, i.e. like a return code in UNIX. Also, is there a better alternative to running OS comma

How to emulate this set or how to assign the result of running system "command" to a variable

2006-08-13 Thread benbart
Hi all, I currently have a MS-DOS batch file that am trying to convert to a Perl script. I have something like this in the .BAT file where variables are "set" based on some parsing of a variable passed as a command line argument whenever the .BAT file is executed by the application. The command l

Re: How to emulate this set or how to assign the result of running system "command" to a variable

2006-08-13 Thread benbart
Hi John, Thanks for your prompt response as usual ... Not exactly need File::Spec and File::Basename per se, I really need to grab some of the environment variables that are set when the Perl script is run or in the case of the .BAT file, when the batch file is run. For example, I want to know w

How to emulate set -x on Perl ...

2006-08-13 Thread benbart
Hi all, In UNIX, we run set -x as some kind of DEBUG mode, how do we do the same in Perl? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Comparing two files of 8million lines/rows ...

2006-08-16 Thread benbart
Hi all, I have two database tables, one is local and one is on a WAN. They are supposed to be in-sync but they at the moment, they are not. There are 8million+ plus rows on this table. I tried to do SELECT EMPNO FROM EMP WHERE EMPNO NOT IN ( SELECT EMPNO FROM [EMAIL PROTECTED] ), leave that runni

How do I do this on Perl ...

2006-08-22 Thread benbart
Hi all, I used to do this on UNIX scripts ... #!/usr/bin/ksh vowels="a e i o u" for letter in $vowels do echo $letter done How do I do the same in Perl? Is it possible to do this in Perl without having to put vowels into an array and use foreach, i.e., using only a FOR-LOOP, but not necessar

How to do this sed one-liners inside Perl?

2006-08-23 Thread benbart
Hi all, I found the following sed one-liner trick that strips out the spaces that I run as follows: sed 's/^[ \t]*//;s/[ \t]*$//' /tmp/file.txt > /tmp/filea.txt This strips out the spaces in file.txt and cuts down its size from 600M+ to a mere 60M. How do I apply this sed one-liner trick inside

How to grep $string from a file? How to run sed-like commands from Perl?

2006-08-23 Thread benbart
Hi all, Please note the Perl script that am trying to write at end the of this email, after the dashes. I have two files that contains thousands and millions of records of two database tables that are supposed to be replicated and same "similar" amount of records but, unfortunately, they're not.

How to remove duplicates from a file ...

2006-08-23 Thread benbart
Hi all, If I have a file that has ... A A B C D D D E E F F G How do I remove the duplicates via a Perl script? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

How to chek the nth column of a delimited file

2006-09-10 Thread benbart
Hi all, I have to re-process a delimited file but I only need to proceed records from the file that satisfy a specific condition. Can someone advise what is the best way to do this? For example, if I have this file here A~BB~CCC~DDD~~D~ A~BB~CCC~DDD~~D~ A~BB~CCC~DDD~~U~3

DBI - DB2 Perl Script ... TWiki

2006-09-28 Thread benbart
Hi all, I have this script that am trying to use to connect to DB2. At the moment I cannot get the script to connect to DB2. In the UNIX prompt, if I run . /home/db2inst1/sqllib/db2profile first and then run the Perl script, then I can connect to DB2. Also, I can only do export DB2INSTANCE=db2i

DatabasePlugin for DB2 and SQLSERVER on TWiki ...

2006-09-28 Thread benbart
Hi all, Am trying to setup TWiki to connect to DB2 and SQLSERVER and needs to configure the DatabasePlugin.pm and DatabasePluginConfig.pm. So far, am not having any luck with them. Already, the notes/docs said the plugin had been tested on MySQL and ORACLE databases only but since I was able to wr

Just asking ... why the dot or no dot

2006-10-18 Thread benbart
Hi all, Just want to know what really is the difference when running a script as . myscript or simply myscript, i.e. the first one with a dot infront of it and the other one without a dot. Or does it matter only when invoking the script from within a script? Any thoughts will be very much appre

How to parse UNIX commands ...

2006-10-26 Thread benbart
Hi all, How do I parse or evaluate the output of UNIX commands? For example, in UNIX scripts, I can run filesystem=`df -k | awk -F"" ' { print $6 }'` to check for the mount points. How do I achieve the same in Perl? That is, I tried: #!/usr/bin/perl $x=system 'df -k'; print "===

Perl connecting to Oracle and SQL Server databases ...

2006-12-17 Thread Benbart
Hi all, Does anyone know of any resource that I can go to for example on connecting to Oracle and Microsoft SQL Server databases using Perl ??? I need more than connecting to the database, some example on how to do SELECT, INSERT, UPDATE and DELETE will be very helpful as well. Thanks in