Running a script in a Jail

Status
Not open for further replies.

JoeB

Contributor
Joined
Oct 16, 2014
Messages
121
Guys- I'm trying to learn to script with sh.

I thought it would be a good idea to do this in a jail so as not to destroy anything on my server, so I have created a vanilla jail with the GUI, added storage to it via the GUI.

Back to windows, I have created a script "t.sh" in the folder that is mounted in the test jail.

Next i have SSH'ed into the jail as root and i can see my script. I have given it 777 permissions and set the owner to root.

root@testscripting:/mnt/test # ls -l
total 9
-rwxrwxrwx 1 root 1001 466 Sep 24 12:20 t.sh

However, the script won't run:

root@testscripting:/mnt/test # ./ t.sh
./: Permission denied.
 

JoeB

Contributor
Joined
Oct 16, 2014
Messages
121
I ended up running like this:
/bin/sh ./t.sh

Wrote 2 scripts, one to automate the install of openvpn and another to check if openvpn is running in a jail and if not restart it.
Works fine, no error checking, but at least I managed to get something working :D
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
/bin/sh ./t.sh
That should work, but did you try what I suggested? The problem that you posted about was because of the space between the / and the t. If your script was constructed correctly (i.e., with a shebang line specifying the shell at the beginning), there's no need to explicitly invoke the shell.
 

JoeB

Contributor
Joined
Oct 16, 2014
Messages
121
Yes that did work. I had the shebang wrong too.
 
Status
Not open for further replies.
Top