Having problem with a bash script
a few days ago this was working fine but now it will print the song name on the screen and doesn't go away like its supposed to(specified by the ``-d" option for osd_cat). anyone see something wrong? and wth did it work fine a few days ago? also, any general programming tips would be appreciated as this is really the most complicated script i've ever had to write.
#!/usr/bin/env bash
#Options:
SCRIPT_DELAY=5
COLOR=black
POSITION=bottom
OFFSET=-50
MPD_HOST=127.0.0.1
OSD_DURATION=5
#extract just the artist/track name from mpc output
function songname() { mpc | sed '2,3d' ; }
#check if song has changed and break if no. if yes, update MPDSONG and print it on screen
function printsong() {
#if mpc's output is only 1 line, then mpc is stopped, so don't print anything
if [ `mpc | wc -l` == 1 ]
then return 1
else
while [ 1 ]
do
MPDSONG2=`songname`
if [ "${MPDSONG}" == "${MPDSONG2}" ]
then
break
else
MPDSONG=`songname`
echo $MPDSONG | osd_cat -d "${OSD_DURATION}" -p bottom -c black -u red -O 2 -i 6 --offset="${OFFSET}"
--font=-adobe-helvetica-bold-*-*-*-34-*-*-*-*-*-*-*
fi
done
fi
while [ 1 ]
do
MPDSONG=`songname`
sleep $SCRIPT_DELAY
printsong
done
Last edited by _adam_ (2007-10-01 17:08:51)
It is working or me. Though I removed to --font argument from the osd_cat command because I don't have the font installed.
The second infinite loop in the function printsong seems a little useless to me.
Similar Messages
-
Having problems with a shell script
I'm trying to write a shell script that will echo back the command, and ask for confirmation before proceeding with the command.
Here is what I have so far:
Josh:~ josh$ cat ~/Desktop/safe
#!/bin/sh
echo "You have typed: "$1 $2 $3 $4"."
read -p "Are you sure you want to continue? (y/n)" a
if [ "$a" = "y" ]; then
$1 $2 $3 $4
elif [ "a" = "n" ]; then
exit
elif [ "a" != "y" ] [ "a" != "n" ];then
echo "Type y or n."
fi
When I run it, and type n, (y works fine) I get a syntax error: ./safe: line 10: [: too many arguments
Could you please help me fix it?
Thanks!
EDIT: If I change the last "elif" statement to a simple "else", it automatically does that statement anyway when the user types "n".
Is there any better way to end the script when the user types "n"?
Message was edited by: joshz
Message was edited by: joshz
Message was edited by: joshz
Message was edited by: joshzjoshz wrote:
A few q's.
1. you have "n=$#", but never use n. What is that for?
Er... because I originally did it differently and then forgot to go back and delete this line!
2. Why do you set list to a blank string? Just to initialize it?
Yes. Habit. Sometimes it is an error to use an unassigned variable. It would not matter in this case because echo will not complain, but it still appeals to my sense of logic/tidiness. It also means that if I later change something in my script so that an unassigned variable will cause an error, I won't be stymied by a failure I can't explain. (Not really an issue in a script this short but might well be in a longer script.)
3. "sed 's+, $+ and all enclosed files/folders+'" What does it do? What is s supposed to do? I know that s treats a string as a single line, but what's the purpose of that (and the +)? $+ would stand for the end of a line, but repeated one or more times. Why have the +'s?
In this case, s is for substitute. The + is an arbitrary delimeter. A forward slash is standard, but if I use + I don't have to escape the slash in the phrase "and... files/folders". The whole thing says:
Take the piped output from echo and find every occurrence of the pattern consisting of a comma followed by a space followed by an end of line (on every line of the piped input, but there's only one here). Substitute the first occurrence you find (on every line of the piped input, but there's only one here) with a space followed by "and... files/folders".
Also, I ideally want the "and all enclosed files/folders" to appear only if there is a recursive option turned on, not all the time. (I guess it would be good enough to have it turn on if there's an r OR R option, because it would be too hard to program it in based on each command).
To do that properly, you need to do things differently so that you can distinguish between arguments to the command and occurrences of strings in the names of files and folders. For example, you might have a folder named "My Folder-Revised". There are ways of doing this but they are not as simple as the sort of framework you're using here.
If you are concerned about accidentally deleting files, have you considered using an alias called "rm" for "rm -i". That way, you do not have to remember to use "safe" either. Unfortunately, that won't work for "sudo rm". On the other hand, "sudo safe" won't necessarily work either. Where are you planning to install your script?
- cfr -
Problems with close event scripts and closing Photoshop
Hi!
We are having problems with close event scripts ("Cls ") when closing/quitting Photoshop.
The close event scripts are working without problem when closing an image. But when quitting Photoshop without having closed all images we are observing the following behaviour:
with CS2 the close event scripts are not triggered at all
with CS4 the close event scripts are triggered and executed correctly. But after that the Photshop process freezes. No visible GUI, you have to kill the process with the task manager.
I can reproduce this behaviour even with a small script consisting of a single alert('hello') and even an empty script. Is this an known bug or am I doing something wrong?
Thanks for your help!
EricCheck your energy saver settings under system preferences. That is where you set sleep setting.
-
Having problems with a message saying,A script in this movie is causing adobe flash player to run slowly if it continues to run, your computer may become unresponsive. Do you want to abort script. And my system seems to freeze. What can I do
Here is the download page for Click-to-PlugIn:
http://hoyois.github.com/safariextensions/clicktoplugin/ -
Having Problem with JSP In Netscape!HELP!!!
HI to all! I�m having problem with the jsp that i have :( If i use the Internet explorer it works but at Netscape... it doesn�t work :( The value of "PTE" is null... I need help !!!Please! I think the HTML IS NOT HELPING ...
the code is :
<html>
<head>
<!--tp001_transferencias_oic_POR.jsp-->
<title>BBVA - Transferências - Transferências OIC</title>
<LINK rel=STYLESHEET type='text/css' href="estilos/tablas.css">
<!--script language="javascript" src "js/dynlayer.js"></script-->
<script language="Javascript" src="js/banner.js"></script>
<script language="Javascript" src="js/tp_oic.js"></script>
<script language="Javascript" src="js/utilidades.js"></script>
<script language="javascript" src="js/limpar.js"></script>
<script language="javascript" src="js/tiempo.js"></script>
</HEAD>
<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0" class="pag-contenido" onLoad="controlSesion();">
<%@ include file ="includecbtf.jsp" %>
<% String s = (String)datos.get("dt");
java.util.StringTokenizer str = new java.util.StringTokenizer(s, "-");
String anoServer = str.nextToken() ;
String mesServer = str.nextToken() ;
String diaServer = str.nextToken() ;
%>
<!--1�form-->
<form method="post" name="captura" action="<%=urls.get("action")%>">
<center> <!--1�center-->
<br>
<!--1�table-->
<table border="0" cellpadding="0" cellspacing="0" width="500"> <!--table das transf e nome-->
<tr>
<td colspan="3"><img src="images/linea.gif" border="0"></td>
</tr>
<tr>
<td width="250"><img src="images/traspasos.gif" border="0"></td>
<td width="82"><img src="images/titular.gif" border="0"></td>
<td width="169" class="fondotitular"><font class="texttitular"><%=datos.get("usuario")%></font></td>
</tr>
<tr>
<td colspan="3"><img src="images/linea.gif" border="0"></td>
</tr>
</table> <!--Fim do 1� table-->
<br><br>
</center> <!--Fim do 1� Center-->
<center> <!--2� Center-->
<!--Conteudo do table 2-->
<table cellpadding="3" cellspacing="1" border="0" align="center" width="500"> <!--table referente a mensagem-->
<tr>
<td class="cabeceratitulo" colspan="2"><p class="titulotabla">Nota : As Transferências para outras Instituições de Crédito decorrem de acordo com os horários da Compensação Interbancária, não se responsabilizando o BBVA pela sua realização fora das regras em uso.</p></td>
</tr>
<tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr>
</table> <!--fim do table2-->
</center> <!--Fim do 2� Center-->
<center> <!-- Inicio 3� Center-->
<!--Conteudo da table Combo-->
<!--Table3-->
<table cellpadding="3" cellspacing="1" border="0" align="center" width="500">
<tr>
<td class="cabeceratitulo" colspan="2"><p class="titulotabla">Transferência Conta a Conta para outras Instituiçôes de Crédito</p></td>
</tr>
<tr>
<td class="formgrisosc" width="100">
<p class="dato">Conta Ordenante: </p></td>
<td class="formgrisosc" width="300">
<%
java.util.Vector v = (java.util.Vector)(datos.get("ListaCuentas"));
java.util.Hashtable elem;
java.util.Enumeration e = v.elements();
%>
<!--1� Select-->
<select name="conta" size="1" class="formgrisosc">
<%
while (e.hasMoreElements()){
elem = (com.ibm.dse.base.Hashtable)(e.nextElement());
String cuenta = ((String)elem.get("s_banco")).trim() + "-"+((String)elem.get("s_oficina")).trim()+((String)elem.get("s_dcontrol")).trim()+((String)elem.get("s_num_cuenta")).trim();
out.println("<option value=\"" + ((String)elem.get("s_tipo")) + "$" + ((String)elem.get("s_clave_asunto")) + "\">" + cuenta + "</option>");
%>
</select> <!--Fim do 1� Select-->
</td>
</tr>
<tr>
<td class="formgriscla" width="100"><p class="dato">Data de Processamento:</p></td>
<td class="formgriscla">
<input type="text" name="dia" size="2"class="formgriscla" value="<%=diaServer %>" maxlength="2" class="formgriscla"> /
<input type="text" name="mes" size="2"class="formgriscla" value="<%=mesServer %>" maxlength="2" class="formgriscla"> /
<input type="text" name="ano" size="4"class="formgriscla" value="<%=anoServer %>" maxlength="4" class="formgriscla"></td>
<input type="hidden" name="dact" size="2"class="formgriscla" value="<%=diaServer %>" maxlength="2" class="formgriscla">
<input type="hidden" name="mact" size="2"class="formgriscla" value="<%=mesServer %>" maxlength="2" class="formgriscla">
<input type="hidden" name="aact" size="4"class="formgriscla" value="<%=anoServer %>" maxlength="4" class="formgriscla"></td>
</tr>
<tr>
<td class="formgrisosc" width="100"><p class="dato">Moeda: </p></td>
<td class="formgrisosc"><p class="dato">
<!--Select 2�Ver este bem-->
<select name="Moeda" size="1" class="formgrisosc">
<option value="PTE" selected>Escudos</option>
<option value="EUR">Euros</option>
</select> </p>
</td>
</tr>
<tr>
<td class="formgriscla" width="100"><p class="dato">Importância:</p></td>
<td class="formgriscla"><input type="text" name="importancia" size="20" maxlength="15" class="formgriscla"></td>
</tr>
<tr>
<td class="formgrisosc" width="100"><p class="dato">Refêrencia:</p></td>
<td class="formgrisosc"><input type="text" name="ref" size="15" maxlength="10" class="formgrisosc"></td>
</tr>
<tr>
<td class="formgriscla" width="100"><p class="dato">NIB Beneficiário:</p></td>
<td class="formgriscla"><input type="text" name="nibBeneficiario" size="30" maxlength="21" class="formgriscla"></td>
</tr>
<tr>
<td class="formgrisosc" width="100"><p class="dato">Descrição p/ Conta Débito:</p></td>
<td class="formgrisosc"><input type="text" name="debito" size="45" maxlength="45" class="formgrisosc"></td>
</tr>
<tr>
<td class="formgriscla" width="100"><p class="dato">Descrição p/ Conta Crédito:</p></td>
<td class="formgriscla"><input type="text" name="credito" size="45" maxlength="45" class="formgriscla"></td>
</tr>
<tr>
<td class="cabecera" colspan="2"><img src="images/1x1.gif" width=1 height=3 border="0"></td>
</tr>
</table> <!--Fim do table 3-->
</center> <!--Fim do 3�center-->
<center> <!--Inicio do 4� Center-->
<!--Inicio da table 4�-->
<table border="0" cellspacing="2" cellpadding="0">
<tr>
<td valign="top"><img src="images/limpar.gif" border="0" alt="Apagar"></td>
<td valign="top"><img src="images/continuar.gif" border="0" alt="Continuar"></td>
</tr>
</table> <!--Fim do 4� Table-->
</form> <!--Fim do FORM-->
</center> <!--Fim do 4� Center-->
</body> <!--Fim do BODY-->
</html> <!--Fim do Html-->
Thanks pepole!thanks people! when i try to validate the action "PTE" he gaves me (if i put a ALERT...) null.
the js code is : (Moeda is coin )
//testa amount
// var ent = (f.amount.value);
var tamanho = f.amount.value.length;
var valor = f.amount.value;
decimals = 2; // Apenas pode ter duas casas decimais?
if (((tamanho == 0) || (valor == 0)) && ok)
alert ("A import�ncia tem de ser maior que zero.");
f.amount.focus();
f.amount.select();
ok = false;
else
alert(f.Moeda.value);
if((f.Moeda.value=="PTE") && ok)
for (j = 0; j < tamanho; j++)
xx = valor.charAt(j);
if ((!(xx.match(numeroER)) && ok))
alert ("O Campo Import�ncia deve ser num�rico inteiro.");
f.amount.focus();
f.amount.select();
ok = false;
//if para limitar valor dos Escudos
if (ok)
if (eval(valor) > 1000000)
alert ("The field amount must be maxium 1 000 000 Pte.");
f.amount.focus();
f.amount.select();
ok = false;
else
if (ok)
//function checkDecimals(f.amount, f.importancia.value) {
if (isNaN(valor)) {
alert("O Campo Import�ncia deve ser num�rico e como separador decimal, o ponto.");
f.amount.select();
f.amount.focus();
ok = false;
else {
timeshundred = parseFloat(valor * Math.pow(10, decimals));
integervalue = parseInt(parseFloat(valor) * Math.pow(10, decimals));
if (timeshundred != integervalue)
alert ("Apenas pode ter " + decimals + " casas decimais. Por favor tente outra vez.");
f.amount.select();
f.amount.focus();
ok = false;
if (ok)
{ //if to limit the value of the Euros
if(eval(valor) > 4988)
alert ("The field amount must be maxium 4988 Eur.");
f.amount.focus();
f.amount.select();
ok = false;
}//end of amount -
I'm having problems with the reproduction of documents in Adobe X due to low reproduction quality ¿c
I'm having problems with the reproduction of documents in Adobe X due to low reproduction quality ¿can you help me
Some things to try...
Using Windows Explorer navigate to C:\Program Files (x86)\Adobe\Reader 11.0\Reader, then double-click on Eula.exe and accept the license agreement
Can you open Adobe Reader by itself? If so, try disabling Protected Mode [Edit | Preferences | Security (Enhanced)].
If you cannot open Reader by itself, try to disable Protected Mode in the registry; download, unzip, then run the attached registry script
It could even be a malware issue; see http://helpx.adobe.com/acrobat/kb/reader-core-dll-error.html -
Having problems with Bridge shutting down after saving photo in PS Cs5,,,,,,,,, Also when i attempt to update either PS or bridge get an error message in Adobe application manger "Error loading updater workflow"
Sorry for the late reply. My email firewall has become a little over zealous & sent a lot of my emails straight to my junk email folder, so I have only just now discovered your reply in my junk mail folder.
The only "don't open files exceeding xxx megabytes" instruction I can find in my Prefs, is in the Bridge Prefs for Thumbnails, & mine is set at 1000mb. The biggest files I handle are bigger than 200mb so I should be able to open a few, not just one.
However, this doesn't explain why I can open a psd format file of 180mb, close it, but then can't open a RAW format file of only 26mb immediately after.
I can open the RAW file only if I restart my computer - very annoying!
However, thanks for the advice about the video card & memory.
So, I'm still stuck as to what the issue is. -
Is anyone having problems with the battery heating up and draining the power? Mine has been doing this for about 2 months now.
This is a major problem with Lollipop, but yo said it started 2 months ago. Several people have fixed problem by removing FaceBook And Face book messenger and then re loading the apps again. You might want to clear your cache before reloading. Not sure this is your problem, but worth a try. Good Luck
-
I am having problems with creating my apple id. On the phone it is advising me that the ID is not created and then when i do it online it says that it has been created. Can you advise me on what to do please?
Apple ID FAQ http://support.apple.com/kb/HE37
-
HT1657 I am having problems with sound in my rental movies
We rent movies all the time but lately we are having problems with sound for our movie rentals. We watch the first half hour without a problem than the voice is choppy all the time. Sometimes it is good for five minutes than noting for a while. We have tried everything we could think of with no avail. I could see one movie but the last 5 or so have been the same. Done trying we need to fix this! Help! Any ideas?
First try resetting your iPad by simultaneously pressing and holding the Home and Sleep/Wake buttons until you see the Apple Logo. This can take up to 15 seconds so be patient and don't release the buttons until the logo appears. Try again to see if the problem persists.
If you still have the same issue, it's possible that something is lodged in the earphone jack. This can cause the iPad to think earphones are plugged in when they are not. Use a vacuum to try to suck any dust, lint or other foreign matter from the jack. If that still doesn't work, try CAREULLY using a toothpick. -
Hi Having problem with FACETIME on my IPAD Connects to call but then cuts out , similarly calls in connect & cut out Can someone help. Brian
My ipad is doing the same thing to it won't let me except a incoming call on Facebook and I don't know what to do
-
I am using my Ipad on a remote craftshow site and am having problems with battery lasting 8 hrs. Can I use a 12v rv battery to recharge it or at least maintain the charge over longer periods of time? I have a dc adapter. thanks
You should be able to use the battery if you get a car type charger which recharges mobile devices.
The full size iPads use a 10-12W charger, whereas the mini uses a 5W charger. Many car chargers only supply 5W. But at 5W, the car charger should give you some extra time on your iPad. It would be best to use a 10-12W car charger.
Cheers, Tom -
I am having problems with my music collection, after burning all of my music to the computer I organized it into folders and placed it in the iTunes Folder. As of now i realize this was a mistake. Starting on a new computer now. I cant get my music to transfer from the itunes folder on the old computer? I keep getting error "Can't Read from the source file or disk." Whenever I got to folder properties its always checked read only. But when i play the song it works just fine. Im sure this is just because I added music into itunes folder but is there anyway to fix it?
WMA files are 'window media audio' files, which is a Microsoft format. If you want to add them to your iTunes library on your Mac then you will need to convert them into a compatible format first. If you still have your windows machine then iTunes for Windows can convert them from WMA to MP3 format : https://discussions.apple.com/message/24158701#24158701
Or try a search for, for example, 'convert wma to mp3' to find programs to convert them. -
I am having problem with MDV Studio.
Hello happy guys, whatzup? Guess all ya 'r doing fine? Right!
I am using Dreamweaver from Macromedia Studio 2004. I am having problem with Inserting Record into Access database using the forms I create on my .asp document. I am using IIS and Javascript as my Document Technology. The error I usually have is:
"Technical Information (for support personnel)
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.
/site_files/user_regform.asp, line 78
Browser Type:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/530.5 (KHTML, like Gecko) Chrome/2.0.172.28 Safari/530.5
Page:
POST 41 bytes to /site_files/user_regform.asp
POST Data:
uname=Honesty&pword=admin&MM_insert=form1
Time:
Tuesday, June 02, 2009, 1:49:39 PM"
Please I need assistance on how to solve this problem. Thank you.
Similarly, I don't really know how to write sql strings - I just give commands and Dreamweaver will generate the sql strings. Yet, I still observe errors. But I think, for the sql aspect, I'm undergoing a tutorial note that I downloaded on the internet.
Please help me to solve this error problem at the moment. The sql knowledge is not the problem. I can get that at my leisure.
Thank you.
Eyo Eyo (Nigeria).It sounds like you do not have an internet connection (wifi arcs in the upper left does not mean you have a connection) since Safari does not work also.. Try the following:
- Reset the iPod. Nothing will be lost.
Reset iPod touch: Hold down the On/Off button and the Home button at the same time for at
least ten seconds, until the Apple logo appears.
- Power off and then back on the router
- Reset networks settings: Settings>General>Reset>Reset Network Settings
- iPhone and iPod touch: Troubleshooting Wi-Fi networks and connections -
I am having problems with the new itunes set up ........
when i plug in my iphone or ipod touch it shows in the top right hand corner of itunes
BUT when i click on the shown iphone/ipod the icon its no longer there, i was useing this fine yesterday and it was showing yesterday what is on this ipod and would allow me to add/remove music, but now this option is no longer availlable - i have added a couple of albums to my itunes i can listen to the music from the laptop but cannot sync the ipods to trancefer these albums to the handheld devices -
i have been trying to sort this all day with no luck not sure if there is a problems with itunes or is it something i am doing ????
HELP !!!!!!!!!!!!BOB we need you urgently
Perhaps Bob will see this thread, he is the professor in these cases.
You do not use a WEP password but wpa/wpa2 on router and equipment.
All equipment connects to WiFi, but for your iPad.
Even with all other equipment WiFi off, you cannot connect your iPad.
Your iPad connects to other WiFi nets correctly.
All resets etc done on iPad and Router.
Still I am not sure it is your router for sure, frustrating...
I want to test 2 other things:
1. in your iPad, set everything OFF in Settings/Cellular, turn off/then/on your WiFi, and see whether it will still not connect...
2. If that does not do it: disconnect the router as well as the modem from the power, for 15 seconds, then reconnect the modem, let it fully start, then reconnect the routet let it fully start, turn of your WiFi in iPad, then on, and see whether it will connect.
Maybe you are looking for
-
Set up and Sync issues with Windows 7
I now have a windows 7 computer and cannot seem to find a way to make my Palm m105 set up an sync with my computer. Can someone please guide me to a solution. Thank you Post relates to: Palm m105
-
[SOLVED] Network manager only works as root
Hello everyone, I am brand new to arch and have been quite impressed over the past few days over all it has to offer. Everything has been running quite smoothly and I am now in the process of setting up wireless. I installed network manager and was
-
Checking List of Specific Files exists in Folder
Hi all, Please help and advice business promises that they drop 10 Different Files with TimeStamp. 1. QHP_Group_Association_Benefit_Periods_20140117104957 2. QHP_Out_Of_Pocket_Limit_20140117110805 10.QHP_Strategy_20140117110230 I have a requirement
-
Sorry if this is a stupid question. But I want to how do I find out what the burn speed/rate a dvd is burning? As I've read that lots of people are only getting 2x. Thanks
-
Cisco UCS with FEX system Component requirements
Hi , I am looking for quick suggestion for required components to have a VMware vSAN implemented using FEX system with maximum Fabric trough put. Ideally a configuration for without multipath using single Fabric switch and later on to be able to upgr