O
Orest Kinasevych
I have three perl CGI scripts that successfully pass variables to each
other.
In one of the scripts I created a variable ($user_dir) that contains the
name of a temporary directory that one of the other scripts will create.
I would like to name that directory after the session ID that was passed
from the PHP page that called the CGI. Something like this:
$user_dir = "/tmp/".$sessionid;
But that isn't working at all. What is working is this
("0688b79939fdeb65effac2314a1f934e" being my current session ID):
$user_dir = "/tmp/0688b79939fdeb65effac2314a1f934e";
Meaning that the value of $user_dir is indeed passed to the script that
creates the directory and that script correctly creates the directory
named "/tmp/0688b79939fdeb65effac2314a1f934e".
However, when I try to set the variable as shown earlier:
$user_dir = "/tmp/".$sessionid;
the variable $user_dir doesn't appear to be set, that is, the script
that creates the directory doesn't create one at all.
Testing $sessionid == "0688b79939fdeb65effac2314a1f934e" evaluates to
true. If I do a print $user_dir, $user_dir shows the expected value.
I am fairly adept at PHP but am a Perl newbie. I'm guessing that there
might be something here having to do with "pass-by-reference" (from what
I've gleaned from online documentation) but I can't quite figure it out.
A few more details:
The $user_dir variable assignment occurs within header.cgi. header.cgi
is called from upload.cgi and progress.cgi using a require statement:
require ("./header.cgi");
Bottom line is this:
a) if ($sessionid == "0688b79939fdeb65effac2314a1f934e") # evaluates to true
b) $user_dir = "/tmp/0688b79939fdeb65effac2314a1f934e" # works when used
to create a directory by that name
c) $user_dir = "/tmp/".$sessionid # does not work
One last piece of info:
The set of statements used to create the directory looks like this:
unless (-d "$user_dir")
{
mkdir ("$user_dir", 0777);
chmod (0777, "$user_dir");
}
Thanks for any assistance/tips/pointers!
- Orest
other.
In one of the scripts I created a variable ($user_dir) that contains the
name of a temporary directory that one of the other scripts will create.
I would like to name that directory after the session ID that was passed
from the PHP page that called the CGI. Something like this:
$user_dir = "/tmp/".$sessionid;
But that isn't working at all. What is working is this
("0688b79939fdeb65effac2314a1f934e" being my current session ID):
$user_dir = "/tmp/0688b79939fdeb65effac2314a1f934e";
Meaning that the value of $user_dir is indeed passed to the script that
creates the directory and that script correctly creates the directory
named "/tmp/0688b79939fdeb65effac2314a1f934e".
However, when I try to set the variable as shown earlier:
$user_dir = "/tmp/".$sessionid;
the variable $user_dir doesn't appear to be set, that is, the script
that creates the directory doesn't create one at all.
Testing $sessionid == "0688b79939fdeb65effac2314a1f934e" evaluates to
true. If I do a print $user_dir, $user_dir shows the expected value.
I am fairly adept at PHP but am a Perl newbie. I'm guessing that there
might be something here having to do with "pass-by-reference" (from what
I've gleaned from online documentation) but I can't quite figure it out.
A few more details:
The $user_dir variable assignment occurs within header.cgi. header.cgi
is called from upload.cgi and progress.cgi using a require statement:
require ("./header.cgi");
Bottom line is this:
a) if ($sessionid == "0688b79939fdeb65effac2314a1f934e") # evaluates to true
b) $user_dir = "/tmp/0688b79939fdeb65effac2314a1f934e" # works when used
to create a directory by that name
c) $user_dir = "/tmp/".$sessionid # does not work
One last piece of info:
The set of statements used to create the directory looks like this:
unless (-d "$user_dir")
{
mkdir ("$user_dir", 0777);
chmod (0777, "$user_dir");
}
Thanks for any assistance/tips/pointers!
- Orest