#!/bin/bash
cd "/Users/alemac/Controle Online/api-community"
lsof -t -i :8080
# mata o processo na porta 8080
echo "Matando processos anteriores"
lsof -t -i :8080 | xargs kill -9 2>/dev/null
# abre o diretório correto
echo "Mudando de diretório"
cd /Users/alemac/Controle\ Online/api-community/
# inicia o servidor PHP
echo "Iniciando servidor"
nohup php -S 0.0.0.0:8080 -t public > /dev/null 2>&1 &
# abre o Safari
echo "Abrindo safari"
open -a Safari "http://localhost:8080"
if i run on terminal line by line, it works
if i run the shell file above, from terminal ( ./startAPI.sh ), it works
but if i call it from xojo, it only shows the echo messages
Var sh As New Shell
Var c, r as string
c = "/bin/bash '/Users/alemac/startAPI.sh'"
sh.Execute(c)
r = sh.Result
Because Shell is not a terminal. For instance, if you type env in a terminal and send it to a Shell, they’re vastly different. None of the startup scripts have run. You’ll either need to use full paths for things or you’ll need to execute the user’s startup scripts.
Strip this and > /dev/null 2>&1 & off the command and see if you get any errors back. All of those things are possibly preventing you from knowing if there’s an issue.