calling shell function in schedule agent

15 pts.
Tags:
Lotus Notes
LotusScript
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**"

Else

Do While fileName$ <> ""

cmdStr ={C:Program FilesWinSCPwinscp.exe /console /command "option batch on" "open 10.237.6.55:sftp_lncoe@10.237.6.55 -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"

Loop

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)"

Else

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • 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:
    report
  • 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.
    3,940 pointsBadges:
    report

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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

Following