Bin/bash - xmessage very slow


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bin/bash - xmessage very slow
# 1  
Old 08-13-2017
Bin/bash - xmessage very slow

Hello,

I am showing the start of my script.
I am finding that 'xmessage' is taking about 12-15 seconds to show.
This in a terminal is very quick '/opt/vc/bin/vcgencmd get_camera'.
Is there any way to get 'camera not detected' to show faster.

Regards
Code:
#!/bin/bash

s=$(/opt/vc/bin/vcgencmd get_camera)
sb="supported=1 detected=1"
case $sb in
$s)
echo "Camera detected"
;;
*)
xmessage "Camera not detected !" -buttons ok
exit 1
;;
esac

# 2  
Old 08-13-2017
It isn't xmessage nor bash that is taking so long, it is vcgencmd. With the path that you are using to invoke that command, we have to assume that this command is not a standard part your operating system and has been installed from a third party vendor or written by someone at your company.

Do you have a manual page for this utility? If so, does it saying anything about options or configuration parameters to shorten the time allowed for a device to respond to a probe?

Have you tried the commands:
Code:
/opt/vc/bin/vcgencmd -h

and:
Code:
/opt/vc/bin/vcgencmd -"?"

to see if there are any built-in help messages that might tell you?

If there is an option or configuration value that can be used to shorten the timeout that program uses before deciding that no camera is connected to your system, note that you may get false negatives if you shorten the time too much. Some devices take a while to warm up and be able to respond when they are probed. And, if the camera you're probing is a device that is accessed through a network (i.e., not directly attached to your computer), network delays can exacerbate any delays imposed by the device itself.
# 3  
Old 08-15-2017
Hello,

Thanks for your reply.
I started my script by a different method and got a warning message.
Code:
Warning: Missing charsets in String to FontSet conversion

This I cured for the moment by adding 'LANG=C' before the call to xmessage.
Code:
#!/bin/bash

s=$(/opt/vc/bin/vcgencmd get_camera)
sb="supported=1 detected=1"
case $sb in
$s)
echo "Camera detected"
;;
*)
LANG=C
xmessage "Camera not detected !" -buttons ok
exit 1
;;
esac

The message box appears straight away.
I don't know what this change does to the system.
Is there a way of turning off 'LANG=C" or won't it mattter?
Perhaps saving the existing LANG to a variable and then re-instating.

Regards

Last edited by mad-hatter; 08-15-2017 at 06:28 AM.. Reason: spelling
# 4  
Old 08-15-2017
Quote:
Originally Posted by mad-hatter
Hello,

Thanks for your reply.
I started my script by a different method and got a warning message.
Code:
Warning: Missing charsets in String to FontSet conversion

This I cured for the moment by adding 'LANG=C' before the call to xmessage.
Code:
#!/bin/bash

s=$(/opt/vc/bin/vcgencmd get_camera)
sb="supported=1 detected=1"
case $sb in
$s)
echo "Camera detected"
;;
*)
LANG=C
xmessage "Camera not detected !" -buttons ok
exit 1
;;
esac

The message box appears straight away.
I don't know what this change does to the system.
Is there a way of turning off 'LANG=C" or won't it mattter?
Perhaps saving the existing LANG to a variable and then re-instating.

Regards
You could save the setting of LANG before changing it and restore it later (but this is a little more complicated than it sounds), but the way your current script works, your setting of LANG only affects the behavior of your invocations of xmessage and exit (and exit doesn't care).

An easier way to set the value of LANG only for the execution of one command is to combine them like this:
Code:
LANG=C xmessage "Camera not detected !" -buttons ok

Doing it this way, LANG is set in the environment for that execution of xmessage and does change the setting of lang for any other code in your script.
This User Gave Thanks to Don Cragun For This Post:
# 5  
Old 08-16-2017
Hello,

Thanks for your help.

Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

In Bash shell - the ps -ef shows only the /bin/bash but the script name is not displayed

In Bash shell - the ps -ef shows only the /bin/bash but the script name is not displayed ? Is there any way to get the script names for the process command ? --- Post updated at 08:39 AM --- in KSH (Korn Shell), my command output shows the script names but when run in the Bash Shell... (3 Replies)
Discussion started by: i4ismail
3 Replies

2. Shell Programming and Scripting

Usage of #!/bin/sh vs #!/bin/bash shell scripts?

Some question about the usage of shell scripts: 1.) Are the commands of the base shell scripts a subset of bash commands? 2.) Assume I got a long, long script WITHOUT the first line. How can I find out if the script was originally designed für "sh" or "bash"? 3.) How can I check a given... (3 Replies)
Discussion started by: pstein
3 Replies

3. Shell Programming and Scripting

BASH Slow Under Cron Only!

I've got a BASH script that runs much faster from the command line than when invoked under CRON. Ideas? Priority? IO? (1 Reply)
Discussion started by: gmark99
1 Replies

4. Shell Programming and Scripting

/bin/bash: Event not found.

Hi I'm new to scripting - please help me... I'm trying to run a script written by a friend: #!/bin/bash for aStat in .... do .... done when coping the script to the terminal I get: /bin/bash: Event not found. for: Command not found. (7 Replies)
Discussion started by: atira
7 Replies

5. Shell Programming and Scripting

bin bash decimal compare

I need decimal comparing with if. Check if apache version is less than 2.2.17. I tried this and not working. #!/bin/bash apachever=`/usr/local/apache/bin/httpd -v | head -1 | awk '{print $3}' |cut -d/ -f 2` if ]; then echo "Apache version less than 2.2.17" else ... (7 Replies)
Discussion started by: anil510
7 Replies

6. Shell Programming and Scripting

BIN/BASH.

THANKS UNIX SYSTEM®.I was found my job from UNIX®.I USE MONKEY WRENCH WITH WARTER.I am now studying my studio with UNIX SYSTEM®. THANKS UNIX SYSTEM®. THANKS OUR OPEN GROUP. from Takayasu Sakashita.My name is Takayasu Sakashita. I respect you. Austin.PEACE!Bey bey. Your friend TAKA.Good... (1 Reply)
Discussion started by: administrator®
1 Replies

7. Shell Programming and Scripting

Bash script too slow

I have a bash script that will take approx. 130 days to complete. I am trying to grep a list of 1,144 user ID's out of 41 (1 GB each) files. The 41 files were originally one 41 G file, but that was horrendously too slow.:eek: This is my current file: #!/bin/bash for i in `cat... (11 Replies)
Discussion started by: tigta09
11 Replies

8. Shell Programming and Scripting

/bin/bash - variable substitution.

Is it possible with a bash variable to perform multiple substitution strings to one variable? I have this variable: echo $clock TIMEZONE="US/Central" What I would like to do with bash only it pull out just the "US" part of the variable.. which could be any number of countries. this is... (6 Replies)
Discussion started by: trey85stang
6 Replies

9. Shell Programming and Scripting

#!/bin/bash has stopped working

Hi I'm writing a script and I've put #!/bin/bash as the first line so that I can just type my scripts name 'whodate' at PS1 instead of ./whodate. This has suddenly stopped working for me. It used to be the case that I could start a script with #!/bin/bash and it would work, but for this script... (2 Replies)
Discussion started by: zorrokan
2 Replies

10. UNIX for Advanced & Expert Users

xmessage

i want to maximise the xmessage window?for that what i have to do? (1 Reply)
Discussion started by: lakshmananindia
1 Replies
Login or Register to Ask a Question