0

I am testing my perl code. I want to pass filepath as a paramter to the URL of the page.

The perl code is dependent on this filepath entirely.

When i set the filepath inside my perl code. (hard coded path), i am able to execute the perl code without any errors. Here is the variable

my $filename="\\\\sfoaepmdata.dcc.com\\folder\\data.txt";

If i pass it via URL, it doesnt work as expected. Can anyone suggest how to pass filepath as a variable in the URL ?

Here is what all i tried to someohow transfer $filename from url to perl code.

http://apmqa.dcc.com/cgi-bin/test/editor.pl?filename=\\\\sfoaepmdata.dcc.com\\folder\\data.txt
http://apmqa.dcc.com/cgi-bin/test/editor.pl?filename=\\sfoaepmdata.dcc.com\folder\data.txt 
http://apmqa.dcc.com/cgi-bin/test/editor.pl?filename=//sfoaepmdata.dcc.com/folder/data.txt
http://apmqa.dcc.com/cgi-bin/test/editor.pl?filename=////sfoaepmdata.dcc.com//folder//data.txt 
http://apmqa.dcc.com/cgi-bin/test/editor.pl?filename=file://sfoaepmdata.dcc.com/folder/data.txt
http://apmqa.dcc.com/cgi-bin/test/editor.pl?filename=file:////sfoaepmdata.dcc.com//folder//data.txt
http://apmqa.dcc.com/cgi-bin/test/editor.pl?filename=http:////sfoaepmdata.dcc.com//folder//data.txt
http://apmqa.dcc.com/cgi-bin/test/editor.pl?filename=http://sfoaepmdata.dcc.com/folder/data.txt

The above data may seem confusing. But please only read values after ?ffilename. Can anyone pls suggest.

I also tried passing other normal paramters and it worked. for e.g. $account=GEL; the filepath doesnt work.

http://apmqa.dcc.com/cgi-bin/test/editor.pl?account=GEL
2

1 Answer 1

1

the solution was pretty simple. i first need to get the user parameter converted to perl and then work on it accordingly.

$filename   = $cgi->param('filename');

By this code, we will get the filepath from the user in $filename and we can work on the required file. Hope it helps someone. thanks.

The passed parameters to the URL would be as shown below

?filename=\\sfoaepmdata.dcc.com\folder\data.txt
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.