Linux script fails.

Seems like a simple script, but it fails with a -127. Any ideas would be great.

thanks

createfile until end
#!/bin/sh
/tmp/SEAClient_lin_State_of_Ohio_SOCC.bin
end
//move __appendfile /tmp/InstallSEA.sh
move __createfile /tmp/InstallSEA.sh
wait chmod a+x /tmp/InstallSEA.sh
if {exists match (case insensitive regex “(linux|esx)”) of name of operating system}
wait sh /tmp/InstallSEA.sh > /tmp/seaout.txt 2>&1 &
//wait /tmp/SEAClient_lin_State_of_Ohio_SOCC.bin
else
wait ksh /tmp/InstallSEA.sh
endif

Try running it as

wait /bin/sh -c “/tmp/InstallSEA.sh > /tmp/seaout.txt 2>&1”

Oh, also, try deleting the file from /tmp before copying or moving over that path. Bigfix will not replace the file if it already exists, and will fail with an error message if that is the case.

Well, here is the out put of when I ran it from the script;

/tmp/InstallSEA.sh: line 2: 21780 Segmentation fault (core dumped) /tmp/SEAClient_lin_State_of_Ohio_SOCC.bin

But if I run exactly the same command on the console, it works fine. I can’t figure out a way around it.

In that case it may have to do with the environment. The BigFix session is not running though a login shell and so may not have some environment variables populated that maybe your script or the binary depends upon.

You might try forcing it to run as a login shell (which sources the root account’s dot-files to build the environment) via

wait /bin/sh --login -c “/tmp/InstallSEA.sh > /tmp/seaout.txt 2>&1”

Also, check whether you have SELinux, fstab options, or any other security package that might block running executables from the /tmp path.

That was the ticket! THANK YOU!

You’re very welcome…which part was it? The login shell, or execute rights on /tmp ?

login shell. I knew there was a difference in the environment that had something to do with the login, but I didn’t know how to overcome it.

Thanks again

1 Like

Jason, I may have to put you on the payroll, but I have one last question; How do I cause the client to restart on a failure on linux. I could do it if it were systemd, but it has that init file and i am not that smart.

If you are trying to restart the client from an Action/Task, the

client restart

command will restart the client, and works cross-platform.

Outside of the BES Client, from a root shell on Red Hat, you can use

service besclient restart

or

/etc/init.d/besclient restart

I understand that. If you were using a straight up service file, the option of “Restart=on-failure” is availble. Inittab would make a “respawn” work. But if you have this mesh of the two, is there a ready made option or do you have to like run a cron job or something.

Thanks