chinmay101
Contributor
Contributor

How to get return from command class ?

Hi Team, I am trying to create a simple workflow (vro 8.4 version) in which the first step is to check if there is a specific folder that exists in vro filesystem(/tmp/folder-xyz) or not  If yes then create a file inside it(/tmp/folder-xyz/file1.txt). I am using the command class for this purpose.

for creating file:

 

 

cmd1 = "touch /tmp/folder-xyz/file1.txt"
command = new Command(cmd1)
command.execute(true)

 

For directory check

 

var cmd2 = '[ -d "/tmp/folder-xyz" ] && echo "Directory /tmp/folder-xyz exists."'
command = new Command(cmd2)
command.execute(true)

 

The directory check command I want to return the above echo statement if it exists but I don't know how to do that. I have tried 

command. output = It's not returning anything
command. result = Its always returns 1
Labels (1)
  • to

0 Kudos
1 Reply
bsaxe
VMware Employee
VMware Employee

The Command class is disabled by default:

https://docs.vmware.com/en/vRealize-Orchestrator/8.6/com.vmware.vrealize.orchestrator-install-config...

For temp directory access, you want to use System.getTempDirectory() and the File class. E.g. new File(System.getTempDirectory() + "/temp.txt").exists;