CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
System command and vector as input

 



yasdel
Novice

Sep 10, 2010, 3:02 AM

Post #1 of 3 (2031 views)
System command and vector as input Can't Post

Hello .

I am trying to use system command to perform a particular task on a group of input files; When I provide the file nales one by one my code works but if I want to provide the file names as a vector it fails.

@resultad is a vector containg filepath/name. Do you know what the problem is please? I checked the code Perl_XMLparsing.pl and I am sure it does not recieve the files (@resultad) ...

$data_fileOut="/tsi/hadrien/deldjoo/Desktop/gresult.txt";
system("perl Perl_XMLparsing.pl @resultad $data_fileOut");

In perl Perl_XMLparsing.pl my code starts with :

use XML::Simple;
use Data::Dumper;
# create object
$xml = new XML::Simple(KeyAttr=>[]);
$size=$#ARGV;
print "# of input files = $size \n"

the error :

# of input files = 0
Can't open result.txt!
/tsi/yacast/20100323/Annotations/2010/03/15/165038/Advertising.xml: line 1: syntax error near unexpected token `newline


rovf
Veteran

Sep 10, 2010, 5:33 AM

Post #2 of 3 (2018 views)
Re: [yasdel] System command and vector as input [In reply to] Can't Post

You show a part of your program, but you don't show that part where the error occurs. From the message, I would guess that XML::Simple is complaining about an incorrect XML file, so maybe you should have a look at this file using a hex editor.


BillKSmith
Veteran

Sep 10, 2010, 6:46 AM

Post #3 of 3 (2011 views)
Re: [yasdel] System command and vector as input [In reply to] Can't Post

How does Perl_XMLparsing.pl parse the command line? The scalar $data_fileOut is not always in the same place.

Does Perl_XMLparsing.pl work with a vector on the command line?

Your argument to system is a single string. Try storing that string in a variable and examine that variable with Data::Dumper to prove that it contains exactly what you think.

Are there any special characters in your file names (e.g. whitespace or backslash)? This causes big problems with system on windows, but usually not on other operating systems.
Good Luck,
Bill

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives