calling shell function in schedule agent

15 pts.
Lotus Notes
i have lotus notes agent code which is working fine when we run manually but its not working in scheduled agent my code below:

Sub Initialize

On Error Resume Next

pathName$ = "E:SFTP" 'Pathname should contain the flatfile location fileName$ = Dir$(pathName$, 0)

If fileName$ = "" Then

Messagebox "**There are no files to upload**"


Do While fileName$ <> ""

cmdStr ={C:Program FilesWinSCPwinscp.exe /console /command "option batch on" "open -hostkey="ssh-rsa 2048 21:cf:39:96:35:72:2c:97:d1:ff:19:8c:85:50:ed:a2"" "cd /sftp/home/sftp_lncoe/AUAR/" "put E:SFTP"} & fileName$ & { "close" "exit"" }

Msgbox cmdStr retVal=Shell(cmdStr, 3) 'Executing the command line statement

fileName$ = Dir$() 'Looping the all files in the folder 'fileName$ = ""

Messagebox "end while"


End If

If retVal = 33 Then 'Shell method returns 33 on completing the execution.

Messagebox "You have successful uploaded files to SFTP server(Temporary prompt)"


Messagebox "Failed to upload" & CStr(retVal)

End If

End Sub

Answer Wiki

Thanks. We'll let you know when a new response is added.

You didn’t say what exactly isn’t working. Does the code not run at all, run but give you an error msg, run but not do what is expected? If it runs, where does it die – the shell cmd?

Is the drive e:\sftp a mapped drive? Is there security on the directory?

Discuss This Question: 2  Replies

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Ganes
    Hi, Thanks for ur response.. actually its working fine in manual running(i.e., its transfer file to sftp server and show successful msg) but when the agent scheduled its running without any error and shows successful message also but the problem is (file not present in sftp server).. please help me to solve this.. I m using winSCP software for sftp..
    15 pointsBadges:
  • Stiletto
    More questions: when running as a scheduled agent, where is the agent running (on the server or on the client)? Do you have the agent set to "run on behalf of" some ID? You didn't answer the question about whether or not Drive E is a mapped drive and if it has security on it, or if there is security needed to run winscp. Does /sftp/home/sftp_lncoe/AUAR have security on it? Also, as far as your code goes, you're only checking for success or failure outside of your loop. That means you're only getting a msg about the last time the shell cmd executes (last file processed). I realize that's not the current problem, but once you get the execution problem resolved, it could become an issue later.
    5,035 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: