Reputation: 1516
I am using the PHP function ssh2_scp_send
to transfer files from one server to another. The interesting things is that if I write the permission in it's octal form (ie 0644) directly everything works fine. If I instead enclose this in inverted commas or use a variabel this does not work any more.
To be clearer:
This works: ssh2_scp_send($conn, $localFile, $remoteFile, 0644);
Does NOT work: ssh2_scp_send($conn, $localFile, $remoteFile, "0644");
Does NOT work: $permission=0644;ssh2_scp_send($conn, $localFile, $remoteFile, $permission);
Anybody has any idea why this is the case?
Upvotes: 4
Views: 1315
Reputation: 8446
Give decoct()
a chance. I'm not sure this will work, but you can try.
One more thing you can try is to store permissions values into constants with define()
Upvotes: 2
Reputation: 490233
The string may be interpreted as decimal.
Also, what type is $permission
? Try using var_dump()
on it. It may be a string too.
$a = 0644;
$b = (int) "0644";
var_dump($a, $b); // int(420), int(644)
Upvotes: 1