Topic "How to Tell When execution has completed"

Author Message
achiku911
[View user's profile]

Joined: 2014-07-24
Posts: 6
Using Vb.net and wanted to know when I execute a session, how can I tell if that session has completed before I move on to my next session? Currently, it seems like it is launching one sessions and moving to another session. That is making my command collide.

Also, I think because it stays in the same spot for awhile, the execution session may think it is done? What I am executing is a database reindex and since a database maybe large, the command doesn't move for maybe 10 - 15 minutes.
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
Can you show your code. I do not understand the problem. The assembly interface is synchronous.
_________________
Martin Prikryl
achiku911
[View user's profile]

Joined: 2014-07-24
Posts: 6
prikryl wrote:
Can you show your code. I do not understand the problem. The assembly interface is synchronous.



Below is the routine "ReindexDB" that I call from my code to reindex different databases. So, I have 5 different databases that I call one at a time, hoping the current one finishes before the next reindex starts. Some of these databases are big and for some reason it calls the next one before the other one is done. All I want to ensure is how I can check to see if the process is complete before the next one starts.


Public Sub ReindexDB()
Dim mySessionOptions As New SessionOptions
Dim strHostKey As String = ""
Dim strReindexPath As String = "cd /opt/IBM/JazzTeamServer_" & strJazzVersion & "/server; "
Dim strTime As DateTime = DateTime.Now
Dim strNow As String = "MMMM, dddd d, yyyy HH:mm"

frmMain.lblStatus.Text = strHeader + strStatus + "..."
frmMain.lblStatus.Refresh()

If strStatus = strCLMName Then strHostKey = strCLM
If strStatus = strRTCDevName Then strHostKey = strRTCDev
If strStatus = strCCM2Name Then strHostKey = strCCM2
If strStatus = strCCM2DevName Then strHostKey = strCCM2Dev

With mySessionOptions
.Protocol = Protocol.Scp
.HostName = strStatus
.UserName = strUserName
.Password = frmMain.txtPassword.Text
.SshHostKeyFingerprint = strHostKey
End With

Using mySession As Session = New Session
mySessionOptions.AddRawSettings("Shell", "pbrun su - vobadm")
mySession.Open(mySessionOptions)

Dim dumpCommand As String = String.Format(strReindexPath + strRunCommand + " >" + strDumpPath + "DB_Reindex/" + strStatus + strLogFile)
mySession.ExecuteCommand(dumpCommand)

strAttachment = strLogPath + "DB_Reindex/" + strStatus + strLogFile
End Using

frmMain.dgvInfo.Rows.Add(strHeader + strStatus + " @ " + strTime.ToString(strNow))
frmMain.dgvInfo.Rows.Add(" ")

For Each line As String In System.IO.File.ReadAllLines(strLogPath + "DB_Reindex/" + strStatus + strLogFile)
frmMain.dgvInfo.Rows.Add(line)
Next

frmMain.dgvInfo.Rows.Add(" ")

frmMain.dgvInfo.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
frmMain.dgvInfo.AutoResizeColumns()
End Sub
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
Again, the assembly interface is synchronous, including Session.ExecuteCommand. So it won't exit until the command finishes.
_________________
Martin Prikryl
achiku911
[View user's profile]

Joined: 2014-07-24
Posts: 6
prikryl wrote:
Again, the assembly interface is synchronous, including Session.ExecuteCommand. So it won't exit until the command finishes.


That is not what is happening. The command completes and it moves to another new session while I can see the PID of the previous process still active.

The reason I noticed is the database cannot index on two process at the same time. I get an error message that the previous index has not yet completed.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
What PID? Of a local WinSCP process or remote "database update" process? If the latter, than it's because your command spawns a child process that continues to run asynchronously. That's something WinSCP cannot control. You have to ensure the parent command does not exit before the actual (child) process.
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License