Combining prefetch and UNIX Shell commands in a task

On a Solaris system, I am attempting to download an installation file and then execute that file to install the needed software.

I currently have a task that contains the following Action Script:

prefetch UPC_6.0_Install.gz sha1:8e7e4aea5e1efde9acefa21227c7761ea48481db size:5790111 http://somesite.com/software/UPC/UPC_6.0_Install.gz

wait mv __Download/UPC_6.0_Install.gz /var/tmp

wait /usr/bin/gunzip /var/tmp/UPC_6.0_Install.gz

wait chmod u+x /var/tmp/UPC_6.0_Install

wait /var/tmp/UPC_6.0_Install

wait rm /var/tmp/UPC_6.0_Install

Would it be better to break this up into 2 tasks (1 to do the prefetch and one to do the install)? I had originally tried to use a __createfile to contain the shell commands, but that didn’t seem to work correctly when placed after the prefetch.

delete __createfile

createfile until End_Of_File
#!/usr/bin/ksh

mv __Download/UPC_6.0_Install.gz /var/tmp
cd /var/tmp
/usr/bin/gunzip UPC_6.0_Install.gz
chmod u+x UPC_6.0_Install
./UPC_6.0_Install
rm UPC_6.0_Install

End_Of_File

wait ksh __creatfile

parameter "error" = "{exit code of action}"

if {parameter "error" != "0" }
	exit {parameter "error"}
endif

I saw a mention of a prefetch block in another post. Am I not calling the prefetch command correctly?

Thanks,
Bob_K

Hi Bob

The difficulty you are experiencing has to do with paths to special files and folders. Only our Action Script commands correctly know how to determine the path to __Download or __createfile. Once you use a shell command you have to explicitly define the path because they do not know how to do the interpretation.

For Example:
move __Download/somefile /tmp/somefile Will work because our “move” command knows how to generate the path to __Download
wait mv __Download/somefile /tmp/somefile Will NOT work because the shell command “mv” has no idea how to generate the actual path to __Download
wait mv {client folder of current site}/__Download/somefile /tmp/somefile Will work because the Relevance substitution will provide the actual path to “somefile”

For simplicity, I like to use the Action Script “move” command to put everything in /tmp/ so that my paths are short. Also, when using __createfile, you will most likely need to change the files permissions prior to executing. You might also need to wrap it in a launching file if you want access to stdout and stderr.

For Example:
move __createfile /tmp/discoverWWN.ksh
wait chmod 777 /tmp/discoverWWN.ksh
delete __appendfile
delete /tmp/launcher.sh
appendfile #!/bin/sh
appendfile /bin/ksh -c /tmp/discoverWWN.ksh > /tmp/discoverWWN.txt 2>&1
appendfile chmod 777 /tmp/discoverWWN.txt
move __appendfile /tmp/launcher.sh
wait chmod 777 /tmp/launcher.sh
wait /bin/sh /tmp/launcher.sh

Additionally you can’t do this. In between each action everything is cleaned up so the prefetch wouldn’t be present unless you moved it outside of the clients directory structures.

This also will not work as parameters are set prior to execution of the action. You should put this inline at the point you want it and protect it as it does not existiduring the download phase I use the following to determine success for example and fail the action if it is not 0

continue if {exists true whose (if true then (exit code of action = 0) else false)}

One other thing the move actionscript gives you over an “mv” is the error detection and retries we have built into our system.

@rkorinek

Thank You,

Bob_K

@AlanM,

I was thinking of making this into 2 tasks, and then I started working on it as one task, and I guess I just didn’t want to give up on doing it that way…

As it is, I have another task that uninstalls the previous version of the program., prior to downloading and installing this version. I created a baseline which runs the uninstall task, and then run the download/install task, so what’s an additional task!

Thanks,
Bob_K