Hello guys,
I am trying to use Ms. Powershell to automate some analyses for me but I am getting the error as on the title, I am not sure why this is the problem, I have already specified the input file name to the input parameter and still I am getting this error. Would be great if anyone has done this before and can look at my code and let me know what I did wrong please. Thanks very much!
Edit: .inp files name are
T2-150x150x6-D1-0pUR_BEM.inp
T2-150x150x6-D1-0pUR_BEM_2.inp
T2-150x150x6-D1-0pUR_BEM_3.inp
T2-150x150x6-D1-0pUR_BEM_4.inp
T2-150x150x6-D1-0pUR_BEM_5.inp
\\\$jobCommand = job=T2-150x150x6-D1-0pUR_BEM_5 input=T2-150x150x6-D1-0pUR_BEM_5.inp cpus=4
Edit 2: I found the issue, it seems like the \\\$using method within the -ScriptBlock doesn't like how the \\\$jobCommand was defined. Replacing the below
Start-Job -ScriptBlock { abaqus \\\$using:jobCommand }with
Start-Job -ScriptBlock { abaqus job=\\\$using:job1 input=\\\$using:job1INP cpus=\\\$using:jobCPUs }
seems to work. Where job1 is the name of the job, job1INP is the name of the INP file and jobCPUs is the number of cpus to run the job.
#
# Script.ps1
#
# Choose a job file containing all the jobs
Add-Type -AssemblyName System.Windows.Forms
\\\$FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{
InitialDirectory = [Environment]::GetFolderPath('Desktop')
Filter = 'Text File (*.txt)|*.txt|Batch File (*.bat)|*.bat'
}
\\\$Null = \\\$FileBrowser.ShowDialog()
# Assign job files directory to path
\\\$myPath = Split-Path -Parent \\\$FileBrowser.FileName
\\\$jobsFile = Split-Path -Leaf \\\$FileBrowser.FileName
Set-Location -Path \\\$myPath -PassThru
Write-Host "Selected jobs file is <\\\$jobsFile> located in \\\$myPath" | Out-Host
#Write-Host "My selected path is \\\$(\\\$myPath)"
\\\$jobsList = Get-Content -Path \\\$myPath'\\'\\\$jobsFile
\\\$jobCPUs = 4
\\\$myJob = foreach(\\\$job in \\\$jobsList)
{
#Write-Host "myJob = \\\$job"
\\\$jobINP = \\\$job + '.inp'
\\\$jobCommand = 'job=' + \\\$job + ' input=' + \\\$jobINP + ' cpus=' + \\\$jobCPUs #+ ' background'
Write-Host "Job Command is < \\\$jobCommand >"
Start-Job -ScriptBlock { abaqus \\\$using:jobCommand }
}
\\\$myJob | Wait-Job -Timeout 15
\\\$myJob | Stop-Job -PassThru | Receive-Job -Wait -AutoRemoveJob
