LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-14-2019, 08:17 AM   #1
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
trying to get fancy with bash conditionals


I got this start up file that I am putting condistionals in to check to see if program is in, if yes then start it, while cutting down on typing letting the system do the most of the work.

it worked with just using this on the dropbox ones so I changed them all to this way and now it is not working at all, so I took it to the terminal to try it in there to see what I get to try and figure this out, so can someone who knows more about the which and how to use it chime in?

the conditionals in question.
Code:
    [[ -x $(which wmix) ]] && $(which wmix) &
        [[ -x $(which wmCalClock) ]] && $(which wmCalClock) &
        [[ -x $(which gkrellm) ]] && $(which gkrellm) &
        [[ -x $(which nm-applet) ]] && $(which nm-applet) &
        [[ -x $(which dropbox)  ]] && $(which dropbox) start &
        [[ -x $(which dropboxd)  ]] && $(which dropboxd) start &
        [[ -x $(which blueberry-tray) ]] && $(which blueberry-tray) &
        [[ -x $(which blueman-applet) ]] &&  $(which blueman-applet) &
        [[ -x $(which qbittorrent) ]] && $(which qbittorrent) &
        [[ -x $(which conky) ]] && 
        [[ -f $HOME/.config/conky/wo-conky-system-lua/WO-conky-system-lua-v3.conkyrc ]] &&
        { $(which conky) -c $HOME/.config/conky/wo-conky-system-lua/WO-conky-system-lua-v3.conkyrc ; } &
        [[ -f $HOME/.config/snitchImages ]] &&  $HOME/.config/snitchImages & 
        [[ -x $(which variety) ]] && $(which variety) &
some of the results, as nothing is starting when I log in, but wmix starts on the cli, and wmCalClock does not because it is not installed.
the ones that are installed start and the ones that are not installed I may be the reson it is not completely working?

which would be a solid yes if the first one was not installed to give a 1 on output, but it is so it should at least start then fail due to the second one not being installed. anyways what is the correct syntax for this?

output to the first three
Code:
[userx@arcomeo ~]$   [[ -x $(which wmix) ]] && $(which wmix) &
[1] 12135
[userx@arcomeo ~]$   [[ -x $(which wmCalClock) ]] && $(which wmCalClock) &
[2] 12140
[userx@arcomeo ~]$ which: no wmCalClock in (/home/userx/bin:/home/userx/.bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl)

[2]+  Exit 1                  [[ -x $(which wmCalClock) ]] && $(which wmCalClock)
[userx@arcomeo ~]$  [[ -x $(which gkrellm) ]] && $(which gkrellm) &
[2] 12143

Last edited by BW-userx; 06-14-2019 at 08:25 AM.
 
Old 06-14-2019, 08:50 AM   #2
wvermin
Member
 
Registered: Jun 2019
Posts: 34

Rep: Reputation: Disabled
I guess the problem is that

test -x
echo $?

yields 0

I would write the start of your script more or less as follows:

#!/bin/bash
for p in "wmix" "wmCalClock" "gkrellm" ; do
which "$p" >/dev/null && "$p" &
done
 
1 members found this post helpful.
Old 06-14-2019, 09:09 AM   #3
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Original Poster
Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by wvermin View Post
I guess the problem is that

test -x
echo $?

yields 0

I would write the start of your script more or less as follows:

#!/bin/bash
for p in "wmix" "wmCalClock" "gkrellm" ; do
which "$p" >/dev/null && "$p" &
done
good Idea, I created a separate list so it can be easily changed to add or remove apps.
Code:
wmix
wmCalClock
gkrellm
nm-applet
dropbox
dropboxd
blueberry-tray
blueman-applet
qbittorrent
variety
created a test script.
Code:
#!/bin/bash

mapfile -t startapps < ~/startapps

for p in ${startapps[@]} ;
do
	which "$p" >/dev/null && "$p" &
done
logout and in because startscript for session is not working so nothing is getting started, then ran my test script and it started everything in it that is installed.

thanks!

I just need to figure these out now. No Big deal.
Code:
[[ -f $HOME/.config/conky/wo-conky-system-lua/WO-conky-system-lua-v3.conkyrc ]] &&
{ $(which conky) -c $HOME/.config/conky/wo-conky-system-lua/WO-conky-system-lua-v3.conkyrc ; } &

[[ -f $HOME/.config/snitchImages ]] &&  $HOME/.config/snitchImages &

Last edited by BW-userx; 06-14-2019 at 10:04 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Yet another bash script question - checking Shadow through a series of conditionals Honest Abe Programming 11 03-30-2019 01:21 PM
Bash script missing matches to conditionals L_Carver Linux - Newbie 7 11-19-2016 11:23 AM
[SOLVED] Problem with BASH conditionals - passing condition as variable smaddox Programming 8 09-18-2009 11:21 AM
configure (automake) conditionals kev000 Programming 0 07-15-2007 12:25 PM
bash scripting - conditionals dguy Linux - Newbie 4 01-19-2002 08:00 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration