I am trying to write a powershell script which call the .ftp file (www.scriptftp.com). When Powershell call the .ftp script file which is use to upload a zip file to ftp server
here is my upload.ftp file code
OPENHOST("www.abcd.in","sdfdsfs","pwd")
CHDIR("/dirctory/from/user/")
$result=PUTFILE("D:\MyZipTest.zip")
IF($result!="OK")
PRINT("ERROR in GetFile, exiting")
# Exit with error code 1
EXIT(1)
ELSE
EXIT()
PRINT("File uploaded successfuly")
END IF
CLOSEHOST
In Above code i return EXIT(1) or EXIT(0) to calling method ie powershell script file
my powershell script file code:
Invoke-Item "D:\USER\Raj\BLACKswastik DEV\FTPScript\Upload1.ftp"
Start-Sleep -Second 15
echo $lastexitcode
echo $?
here i want to fetch exit code which return by .ftp file script so i use $lastexitcode and $? but both of them not showing me proper results.
IS there any other way to fetch the exit code of child process please suggest me.