Custom script deployment

Hi Team,

          Please help me with the below deployment script.

#!/bin/sh
umount /mnt
mount software:/linuxmast /mnt
action parameter query “VALUE” with description "Please enter the desired parameter"
parameter “PROVIDE” = "{parameter “VALUE” of action as trimmed string}"
action parameter query “DATES” with description "Please enter the desired date"
parameter “DATE” = "{parameter “DATES” of action as trimmed string}"
if [[ -f /mnt/apars/linux_apar.sh ]]; then
/mnt/apars/linux_apar.sh “{parameter “VALUE” of action}” "{parameter “DATES” of action}"
else
mount 10.21.12.28:/linuxmast /mnt
if [[ -f /mnt/apars/linux_apar.sh ]]; then
/mnt/apars/linux_apar.sh “{parameter “VALUE” of action}” "{parameter “DATES” of action}"
else
exit 2
fi
fi
umount /linuxmast
exit 0

If I execute the above script. I get an error on line 6. parameter “DATE” = “{parameter “DATES” of action as trimmed string}”. I also tried to run the same in BigFix action script by changing the script according to BigFix action script but still no go. But when I remove the parameters and enter them directly in the script then it works. See for example below.

/mnt/apars/linux_apar.sh -c 2017-05-17

But this date gets changes everytime. So we need those parameters. PLEASE HELP !!!

It looks like you are trying to make a “sh” based script but using “actionscript” commands? That doesn’t exactly work. If you want to use actionscript then you’ll have to build the shell script and run it with actionscript commands.

Hi Alan, Thanks for your quick response. I am trying to run the shell script. In the same script above. Everything works fine if I remove those parameter declaration. So it seems like parameter declaration has got some issue.

Regards,
Ajeeth

In your Action Type, is it set to ‘sh’ or ‘BigFix ActionScript’ ?
If you’re using ‘sh’, you can’t use ActionScript commands like action parameter query or parameter

Instead, as Alan says you’ll need to change the Action Type to ActionScript, use the createfile until or appendfile commands to write out a shell script, and then use waithidden or runhidden to execute /bin/sh /path/to/your/script.sh

I tried both sh and BigFix action script by changing the formate according to the action script. I am aware about using createfile until or appendfile commands but how will that help to declare the parameters. Will that be like below.

Present script:
action parameter query “DATES” with description "Please enter the desired date"
parameter “DATE” = “{parameter “DATES” of action as trimmed string}”
/tmp/some.sh “{parameter “DATES” of action}”

Modified script
appendfile “DATES” with description "Please enter the desired date"
appendfile “DATE” = “{parameter “DATES” of action as trimmed string}”
/tmp/some.sh “{appendfile “DATES” of action}”

Just the parameter declaration part. No matter if you could help me in sh or BigFix action script. I can change the rest of the scripts accordingly. Please help

The thing is, neither of those will work either because they’re mixing Action Script and sh script. Take the “Present Script” -

‘action parameter query’ and ‘parameter’ are actionscript commands, but /tmp/some.sh is not.

‘appendfile’ is still Action Script, and /tmp/some.sh is not.

You probably want something like this (type Action Script) - there may be some bugs here, I don’t have a console to test with, but this should give an idea.

action parameter query "DATE" with description "Please enter the desired date"
delete __createfile
createfile until EOF
#!/bin/sh
echo "My script ran with parameter $1" > /tmp/listing.out
set MYVAR={parameter "DATE" as trimmed string};export MYVAR
echo "MYVAR is $MYVAR" >> /tmp/listing.out
EOF

move __createfile mytest.sh
waithidden /bin/sh mytest.sh {parameter "DATE" as trimmed string"}

Here, it’s all Action Script commands. First we delete any existing file “__createfile”, then use the “createfile until” command to write out a shell script. The script includes relevance substitutions - text between the curly brackets {} is interpreted as relevance and the results are included in the shell script that we’re writing and in the command line parameter we are passing to the script.

To execute the script, you need to use one of the “wait”, “waithidden”, “run”, or “runhidden” Action Script commands to execute the shell script as an external process.