mikkeldamsgaard / slash

A shell scripting language
GNU General Public License v2.0
29 stars 0 forks source link

Releasing an application to background #1

Open MostHated opened 2 years ago

MostHated commented 2 years ago

Hey there, I was trying to test this out and I am having a bit of an issue, I think I might be missing something?

I was trying to simply see if an application is running, if not, start it's daemon, then run a specific configuration.

#!/usr/local/bin/slash

pgrep -l "eww" $> eww_proc
if (stdout(eww_proc) == ""){
  eww daemon    # tried ending with &!, &, using nohup, etc.
  eww open top-monitor   # Same as above
}

I also tried the following:

#!/usr/local/bin/slash

pgrep -l "eww" $> eww_proc
if (stdout(eww_proc) == ""){
  eww daemon && eww open top-monitor 
}

None seem to work properly, though, so I just started trying whatever I could think of, lol. Ex:

#!/usr/local/bin/slash

pgrep -l "eww" $> eww_proc
if (stdout(eww_proc) == ""){
  eww daemon 2> /dev/null &
  eww open top-monitor  2> /dev/null &
}

What might I be missing when trying to run these two commands?

Thanks, -MH

MostHated commented 2 years ago

I wanted to give it another go, so I tried this one as well:

#!/usr/local/bin/slash

ps aux | grep ' [A]ssetImportWorker0 ' | awk '{print $2}' $> unity_proc
if (stdout(unity_proc) != ""){
    print(unity_proc)
}

but received:

[Running] /usr/local/bin/slash "/home/mosthated/_dev/languages/slash/check_unity.sl"
 --> 3:55
  |
3 | ps aux | grep ' [A]ssetImportWorker0 ' | awk '{print $2}' $> unity_proc
  |                                                       ^---
  |
  = expected var_name

[Done] exited with code=1 in 0.015 seconds
mikkeldamsgaard commented 2 years ago

The $2 in the awk argument should be escaped, as slash is trying to substitute. awk '{print \$2}'

mikkeldamsgaard commented 2 years ago

That said, I dont think I ever implemented the running in background part.