A method to cue multiple script sequential execution.

Hello,
Is there a way to have scripts run sequentially with just one act of execution (pardon my jargon or lack thereof)? To be clear: Have a script execute only after the previous has finished?

Thanks,
MJ
mgjustAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MrNevajCommented:
Well at the end of the script you can call the next script
if this is in widows batch you just need to put the commands in in the order you would type them out at the command prompt. if this does not help let me know and i can post a short example. it also might help if you posted a short example of what your trying to do.
0
Robberbaron (robr)Commented:
http://www.tek-tips.com/faqs.cfm?fid=5755   onjShell.run

object.Run(strCommand, [intWindowStyle], [bWaitOnReturn])

bWaitOnReturn
Optional. Boolean value indicating whether the script should wait for the program to finish executing before continuing to the next statement in your script. If set to true, script execution halts until the program finishes, and Run returns any error code returned by the program. If set to false (the default), the Run method returns immediately after starting the program, automatically returning 0 (not to be interpreted as an error code).
Remarks
The Run method returns an integer. The Run method starts a program running in a new Windows process. You can have your script wait for the program to finish execution before continuing. This allows you to run scripts and programs synchronously. Environment variables within the argument strCommand are automatically expanded. If a file type has been properly registered to a particular program, calling run on a file of that type executes the program. For example, if Word is installed on your computer system, calling Run on a *.doc file starts Word and loads the document. The following table lists the available settings for intWindowStyle.



0
mish33Commented:
a.py:
print 'a is running...'

b.py:
print 'b is running...'

run.bat:
@python a.py
@python b.py

cmd> run
a is running...
b is running...

In that example b.py will run only after a.py finished
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

RobSampsonCommented:
Hi, you can use a call to this VBS to wait for one or multiple batch files to finish:

'===================
'MUST BE RUN BY: START /WAIT RunAndWait.vbs script1.vbs script2.vbs
If WScript.Arguments.Count > 0 Then
      strWhileCondition = "Do Until "
      Set wshShell = CreateObject("WScript.Shell")
      For intArgNum = 0 To WScript.Arguments.Count - 1
            strCodeToExec = "Set objExec" & intArgNum & " = wshShell.Exec(""wscript.exe " & WScript.Arguments(intArgNum) & """)"
            Execute strCodeToExec
            If intArgNum < WScript.Arguments.Count - 1 Then
                  strWhileCondition = strWhileCondition & "objExec" & intArgNum & ".Status AND "
            Else
                  strWhileCondition = strWhileCondition & "objExec" & intArgNum & ".Status"
            End If
      Next
      strWhileCondition = strWhileCondition & VbCrLf & "WScript.Sleep 500" & VbCrLf & "Loop"
      'MsgBox strWhileCondition
      Execute strWhileCondition
End If
'===================

And you can use it in a batch file like this:

@echo off
start /wait RunAndWait.vbs file1.vbs file2.vbs file3.vbs
start /wait RunAndWait.vbs file4.vbs

Regards,

Rob.
0
RobSampsonCommented:
Oh, that's for VBS Files...this should work for batches:

'===================
'MUST BE RUN BY: START /WAIT RunAndWait.vbs script1.bat script2.bat
If WScript.Arguments.Count > 0 Then
      strWhileCondition = "Do Until "
      Set wshShell = CreateObject("WScript.Shell")
      For intArgNum = 0 To WScript.Arguments.Count - 1
            strCodeToExec = "Set objExec" & intArgNum & " = wshShell.Exec(""cmd /c " & WScript.Arguments(intArgNum) & """)"
            Execute strCodeToExec
            If intArgNum < WScript.Arguments.Count - 1 Then
                  strWhileCondition = strWhileCondition & "objExec" & intArgNum & ".Status AND "
            Else
                  strWhileCondition = strWhileCondition & "objExec" & intArgNum & ".Status"
            End If
      Next
      strWhileCondition = strWhileCondition & VbCrLf & "WScript.Sleep 500" & VbCrLf & "Loop"
      'MsgBox strWhileCondition
      Execute strWhileCondition
End If
'===================

And you can use it in a batch file like this:

@echo off
start /wait RunAndWait.vbs file1.bat file2.bat file3.bat
start /wait RunAndWait.vbs file4.bat

Regards,

Rob.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mgjustAuthor Commented:
Thank you kindly.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Python

From novice to tech pro — start learning today.