I've a link where I saw the reference to change the default attributes & set the required mode to transfer the dataset through SFTP.
Here is how it is..
sftp> ls /+mode=text,lrecl=80,recfm=fb
In this, we change the mode to text (where default is the binary
mode).
When I execute this through command prompt it works fine and gives the same response which means the command executed perfectly!
(Response after executing in command prompt)
sftp> ls /+mode=text,lrecl=80,recfm=fb
/+mode=text,lrecl=80,recfm=fb
But if I try to use the same through the PHP code it throws me the error as
ls: FSUM6785 File or directory "/+mode=text,lrecl=80,recfm=fb" is not found
Here is how I used using the phpseclib library:
define('NET_SFTP_LOGGING', NET_SFTP_LOG_COMPLEX);
$user = 'username';
$host = 'host';
$key = new Crypt_RSA();
$key->loadKey(file_get_contents('file.ppk'));
$sftp = new Net_SFTP($host);
if ($sftp->login($user,$key)) {
echo $sftp->exec('ls /+mode=text,lrecl=80,recfm=fb');
} else {
return false;
}
In the above if I try with $sftp->exec('ls -la');
and $sftp->exec('pwd');
it gives me the list of directories present & the current directory respectively.. which means the SFTP connection is fine and the exec
command works.
But the same throws error when I use the ls /+mode=text,lrecl=80,recfm=fb
commands as mentioned above.
Is there any other thing that need to be set to make these /+mode=text.....
commands to work