[plug] Script

Andrew Innes andrew.c12 at gmail.com
Tue Sep 19 09:02:04 AWST 2017

Hi Garry

You only use fi after an if, it’s if backwards.

if [ -f /var/log/messages ]
    echo "/var/log/messages exists."

If you want to get rid of the messages do this

transmission-gtk &>/dev/null &

& (the first one) detaches the command from stdin.
>/dev/null detaches the shell session from stdout and stderr.
>From https://stackoverflow.com/a/29681504

Sent from Mail for Windows 10

From: Garry
Sent: Tuesday, 19 September 2017 8:45 AM
To: plug at plug.org.au
Subject: [plug] Script

HI all,

This is going to seem pretty basic, but I don't know the correct words
to search for the answer.

I need to write a quick script to start a program, exit and leave the
program running.
I know at the command line you put "&" at the end to return the command line.

transmission-gtk &

I believe "fi" makes a script exit. But I get a warning message
"(transmission-gtk:*processnum*):WARNING **:Couldn't connect to
accessibility bus: Failed to connect to socket /tmp/dbus-OHNORYryZL:
connection refused
./starttorrent: line 2: syntax error near unexpected token 'fi'
./starttorrent: line 2: 'fi'

And here's the funny thing.. Despite the warning, it works. If I
remove the "fi", it starts, the warning is the same except the lines
referring to "fi" are missing and the script doesn't exit. But it
still starts transmission.

I also tried
transmission-gtk & (and without the &)
exit 0
But it works as though the "fi" was there.

I guess at the end of the day for completeness I'd start with "killall
transmission-gtk" to stop multiple instances, but I don't want to
complicate things at this stage...

Can anyone cast some light on this for me please?


PLUG discussion list: plug at plug.org.au
Committee e-mail: committee at plug.org.au
PLUG Membership: http://www.plug.org.au/membership

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.plug.org.au/pipermail/plug/attachments/20170919/881f7acf/attachment.html>

More information about the plug mailing list