Jump to content

Basic bash script


This topic is 4545 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Here is the output of ls -l from /Library/FileMaker\ Server/Data/Scripts/

-rwxrwxrwx@ 1 fmserver fmsadmin 73 Dec 5 15:17 touch.sh

This is the shell script:


!#/bin/bash

touch /Library/FileMaker\ Server/Data/Documents/touchtest.txt





This is the failure in the FileMaker server logs:





2011-12-05 15:26:59.389 -0500 Information 146 filemaker.hostname.com Schedule "touch" run now by "accountname [123.456.7.8]".

2011-12-05 15:26:59.395 -0500 Error 642 filemaker.hostname.com Schedule "touch" aborted; unexpected error. (-1)

This bash script is being called from a scheduled system script from FMS. Nothing else is attached to it like in a script sequence. I am using the default user ( FMServer ).

What am I missing that is causing this very basic script not to run?

Link to comment
Share on other sites

I actually had that right but in a last ditch effort, I changed it to !# incase for some reason I had that wrong. I copied and pasted that line to the forum. oops. The error remain even with #! Any other thoughts? The script works fine from terminal. It really does not get any simpler than touch to test things out.

Link to comment
Share on other sites

The "@" sign -- which is not documented in the manual page for ls(1) -- indicates that the file has extended attributes. You can use the command 'xattr -l <filename>' to show them.

On touch.sh that command returns:


com.apple.FinderInfo:

00000000  54 45 58 54 21 52 63 68 00 00 00 00 00 00 00 00  |TEXT!Rch........|

00000010  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|

00000020

com.apple.TextEncoding: UTF-8;134217984

Link to comment
Share on other sites

So you're editing with BBEdit ;-)

If you don't know what the root user is, stop here

To act as fmuser without knowing the pw:

- in a Terminal:

# going to root

su

# after entering pw

sudo -u fmserver /Library/FileMaker Server/Data/Scripts/touch.sh

That should execute the script as fmserver.

Link to comment
Share on other sites

The fmserver user was able to execute and create the touch file.

These are the steps I did in terminal. Notice I confirmed I was fmserver.


machine:~ user$ su

Password:

sh-3.2# su fmserver

bash-3.2$ whoami

fmserver

bash-3.2$ /Library/FileMaker Server/Data/Scripts/touch.sh

bash-3.2$

Link to comment
Share on other sites

The default fmserver account probably does not have privileges to do what the script asks. If creating a file, that file must be within the FMS security bubble. if it's outside, then it likely will not work. BTW, use something like the ChangeMOD utility to check the read/write privileges of the script file itself.

Steven

Link to comment
Share on other sites

i was able to execute it under the fmserver user as revealed by my whoami I did just prior to executing the touchtest.sh as seen above in the thread so why would it be different if run under a scheduled script?

The file is being created in the "Bubble" at /Library/FileMaker Server/Data/Documents/

I did use chmod fmserver:fmsadmin on touchtest.sh The ls -l I placed higher in this thread shows the permissions are correct including that the file is executable. Again, I was able to execute it as fmserver when I used su.

What else might I be missing?

Link to comment
Share on other sites

This topic is 4545 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.