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: Beginner:
Executing linux command in a perl script

 



yosr
New User

Jul 8, 2013, 12:50 PM

Post #1 of 5 (195 views)
Executing linux command in a perl script Can't Post

Hi,
I'm a beginner and I have to write a script that extract data from a website.
The data structure is the following:
region > river > station > date > 01.07.2013.csv
region, river, station, date are directories and 01.07.2013 is a file containing informations

the problem is,
a station has the name : ELBE+(ARTLENBURG)
and when my script executes this command : `bash -c 'ls -r $s'`
$s is a variable containing the path of the directory having the name of this region:
I get the following error:

bash: -c: line 0: `ls -r ./pegel/ELBEGEBIET/ELBESEITENKANAL/ELBE+(ARTLENBURG)'
bash: -c: line 0: syntax error near unexpected token `('

you can find the script I wrote as attachment.
and If you have any critics, or you see that I made some errors please tell me how to correct them
I really need your help :(
I have no idea how to fix this error, and I have to fix it as soon as possible.
Thank you very much, and I m sorry for the spelling errors I don't speak english very well


(This post was edited by yosr on Jul 8, 2013, 2:13 PM)
Attachments: extractData.plx (4.80 KB)


BillKSmith
Veteran

Jul 8, 2013, 1:59 PM

Post #2 of 5 (187 views)
Re: [yosr] Executing linux command in a perl script [In reply to] Can't Post

Your attachment did not work, please try again.
Good Luck,
Bill


yosr
New User

Jul 8, 2013, 2:14 PM

Post #3 of 5 (184 views)
Re: [BillKSmith] Executing linux command in a perl script [In reply to] Can't Post

heyy thank you, I hope you can find it now :)


BillKSmith
Veteran

Jul 8, 2013, 9:00 PM

Post #4 of 5 (168 views)
Re: [yosr] Executing linux command in a perl script [In reply to] Can't Post

I can only offer a few observations.

There does not seem to be any problem with your perl. The error message is from bash. I suspect that '(' is not a valid character in a unix directory name.

your text implies that the value of $s should be in the form "./ region / river / station / date / filename". Clearly it is not. So far I do not understand how it is built.


Why are you using bash at all???? Surely you can accomplish this task with pure perl functions.
Good Luck,
Bill


yosr
New User

Jul 9, 2013, 9:55 AM

Post #5 of 5 (157 views)
Re: [BillKSmith] Executing linux command in a perl script [In reply to] Can't Post

heyy thank you for the answer, I changed now my code and used only perl modules.
and it works !!
:)
Thank you very much

 
 


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

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