WinSCP won't run when source file has multiple lines
I have a PHP script to check if a file exist. I am using a source file that contains the files to check. I am using a
foreach
loop to read the source file line by line and check if that line/file exist from WinSCP/remote host. The code does not work when the source file has more than one line. I tried to have the source file have only 1 line and it ran fine. Maybe I am missing a config or a line?
foreach(file("$sourcefile") as $line) { $path="C:\Program Files (x86)\WinSCP"; chdir($path); system("winscp.com /parameter $line /log=C:\Users\USER1\test\log_yesterday.log /ini=nul /script=C:\Users\USER1\test\connect.txt", $excode); if ($excode == "0") { echo "\nFile exist."; } else { echo "File does not exist"; } }