Welcome!
Important information
-- Spectre and Meltdown vulnerabilities
-- Change in MX sources

News
-- MX Linux on social media: here
-- Mepis support still here

Current releases
-- MX-17.1 Final release info here
-- antiX-17 release info here

New users
-- Please read this first, and don't forget to add system and hardware information to posts!
-- Here are the Forum Rules

wait for terminal in a script

Feel free to talk about anything and everything in this board. Just don't post offensive topics that are meant to cause trouble with other members or are derogatory towards people of different genders, race, color, minors (this includes nudity and sex), politics or religion. Let's try to keep peace among the community and for visitors.

No spam on this or any other forums please! If you post advertisements on these forums, your account may be deleted.

Do not copy and paste entire or even up to half of someone else's words or articles into posts. Post only a few sentences or a paragraph and make sure to include a link back to original words or article. Otherwise it's copyright infringement.

You can talk about other distros here, but no MX bashing. You can email the developers of MX if you just want to say you dislike or hate MX.
Message
Author
User avatar
fehlix
Forum Guide
Forum Guide
Posts: 2331
Joined: Wed Apr 11, 2018 5:09 pm

Re: wait for terminal in a script

#11 Post by fehlix » Tue Oct 02, 2018 6:10 am

Adrian wrote:
Mon Oct 01, 2018 11:11 pm
This works though...

Code: Select all

xfce4-terminal --disable-server -x bash -ic "sleep 10" ; echo "terminal terminated?"
OK, @Adrian found the right option!
... so here my short countdown test with this option:

Code: Select all

xfce4-terminal --disable-server -x bash -ic 'echo Count_down; for i in {9..0}; do echo $i; sleep 1; done; read -p Ready_for_Take_Off_Hit_any_key ;'
echo Beam_me_Up_Scotty
:anispider2:
Gigabyte Z77M-D3H, Intel Xeon E3-1240 V2 (Quad core), 32GB RAM,
GeForce GTX 770, Samsung SSD 850 EVO 500GB, Seagate Barracuda 4TB

antiX-Dave
Forum Regular
Forum Regular
Posts: 384
Joined: Mon Apr 16, 2012 4:51 pm

Re: wait for terminal in a script

#12 Post by antiX-Dave » Tue Oct 02, 2018 7:40 am

I think that you can end the command string with the command "bash" in terminal and it will hold the terminal open until you exit the bash session. Not sure if that is what you wanted though.

Vincent17
Forum Novice
Forum  Novice
Posts: 48
Joined: Tue Feb 20, 2018 1:07 am

Re: wait for terminal in a script

#13 Post by Vincent17 » Tue Oct 02, 2018 11:58 am

Thanks for all the educational replies. :happy: I should have been clearer about my exact requirements, but I learned more this way. My applicaton is an interface for encfs, emulating Fatdog developer jamesbond's right-click options in rox. The problem arose in this part:

Code: Select all

#create encrypted folder if it doesn't already exist	
if [[ ! -d "$P/.$F" ]] ; then 	
	xfce4-terminal -x bash -ic "encfs -f $P/.$F $P/$F" 
	until [[ -f $P/.$F/.encfs6.xml ]] ; do sleep 1 ; done   
fi
Now input pwd to open access
If the script continues before the encrypted folder is properly created, open for access fails and the script must be restarted. As you can see, I used the indicator file method since encfs creates an xml file in the encrypted folder, but I wanted to know how to do this in general. I think I count 2 methods so far:

--disable-server option of xfce4-terminal
wait for an indicator file

I learned a lot of useful new stuff even if it doesn't meet this particular requirement.
read -t n does not cause the script to wait for the terminal
bash at the end holds the terminal open, but does not detain the script
command1 && command2 I was using "[[ $? -eq 0 ]] && " for that :azn:

Post Reply

Return to “General”