Shell script runs OK, but needs to keep going and doesn't...

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

Shell script runs OK, but needs to keep going and doesn't...

#1 Post by starhawk »

@rcrsn51, et al. -- the launcher project is on hold until I feel like going back to it. It will eventually get more attention, but that's going to be awhile. Why? Basically I lost interest.

----------

Running X-Slacko 1.1 with the new PetGet patch (THANK YOU rg66!!) Wanted MIDI playback. So I installed Audacious (which I would've anyways, since I like the interface) and ****ed around with FluidSynth until I could get what I wanted.

Problem: fluidsynth doesn't start automatically. So I made a shell script to do that, and stuck it in /root/Startup, but it doesn't /stay/ running once the shell script does its thing, and I'm not quite sure why. A simple symlink to /usr/bin/fluidsynth won't work here -- I have to load the soundfont I'm using (at /root/my-documents/chorium.sf2) as well.

Here's my very simple shell script -- how do I make it work as needed?

Code: Select all

#!/bin/sh
fluidsynth /root/my-documents/chorium.sf2

Last edited by starhawk on Wed 07 Jan 2015, 01:25, edited 1 time in total.

User avatar
Moose On The Loose
Posts: 965
Joined: Thu 24 Feb 2011, 14:54

Re: Shell script runs OK, but needs to keep going and doesn't...

#2 Post by Moose On The Loose »

starhawk wrote:

Code: Select all

#!/bin/sh
fluidsynth /root/my-documents/chorium.sf2

I think you want a "&" on the end of the statement. Try this silly script to see how putting a statement into a different shell works.

Code: Select all

#!/bin/bash

for AA in 1 2 3 ; do
  Xdialog --yesno "are you bored yet" 0 0
  done &

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#3 Post by starhawk »

Code: Select all

#!/bin/sh
fluidsynth /root/my-documents/chorium.sf2 &

...does not work :(

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#4 Post by amigo »

Code: Select all

#!/bin/sh
exec fluidsynth /root/my-documents/chorium.sf2

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#5 Post by starhawk »

That worked! I'm gonna have to do man exec now, since I've never really become familiar with that command... I'd love to know why it worked.

FWIW, my local guru (who I'd also asked) recommended the nohup command, which I found interesting, considering it's more for telecom stuff than anything else, IIRC.

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#6 Post by amigo »

nohup and exec are both bash builtins, so to get help you need to run(from bash shell):
help exec
help nohup

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#7 Post by starhawk »

I tend to run man in a browser, at a google search page... ;)

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#8 Post by amigo »

man is used for help for named programs. Since nohup and exec are from bash, then you'd need 'man bash'. But, the bash manpage is epic in length, so the built in help will get you there faster. The distinction is significant. for instance, there is a program called '['. But, when you use '[' in a script or command-line, the *program* '[' is not used. Insetad, bash or other shell will use its' builtin version.
You can see the difference by running 'man [' and then running from shell 'help ['. You can find out which is really being used by running 'type [' which will show that it is a builtin. Whereas, running 'which [' will show /usr/bin/[. If you compare the man page with the internal help you will quickly see that they are not the same program.

nohup means 'no hangup'. Since you are running the script from a terminal, when you close the terminal it kills the process which you backgrounded (with &).
exec replaces the old process (the terminal) with the new process (fluidsynth).

exec is commonly used, but 'nohup fluidsynth ... &' would also work in this case.

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#9 Post by starhawk »

...now it doesn't work! AAAAAARGH. (I have replaced my savefile between then and now.)

Code: Select all

#!/bin/sh 
exec fluidsynth /root/my-documents/chorium.sf2
...is the entire contents of the file. If I "run in terminal" it works, until I close the terminal window.

Back to square one!

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#10 Post by technosaurus »

it may need a tty
rxvt -e "command here"
you can add parameters to make rxvt small or invisible
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#11 Post by Karl Godt »

Errors from

/usr/sbin/delayedrun
and
/root/.xinitrc

usually got to /tmp/xerrs.log
.


If you have fluidsync in a non-standard PATH
like
/usr/music/bin

but altered .bashrc to add /usr/music/bin to the PATH , then
bash
will recognize the PATH,
but
sh
probably not .

That may be the difference when code runs from terminal but not from a script .

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#12 Post by starhawk »

@techno -- it didn't need a tty before... it "just worked".
@Karl -- Fluidsynth is in /usr/bin and it has two libs in /usr/lib. xerrs.log doesn't reveal any secrets -- at least, not to me. It clearly runs... but for some reason it doesn't /stay/ running.

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#13 Post by Karl Godt »

If you also want to
deactivate the use of the shell, start FluidSynth with the -i option:
'fluidsynth -ni soundfont.sf2 midifile1.mid midifile2.mid'
http://www.manualpages.de/FreeBSD/FreeB ... nth.1.html

Then /etc/init.d/10_alsa needs to finish plus the loading of drivers .

Puppy forks the loading of drivers using UDEV and /etc/rc.d/rc.servuces start & script .

When you are "unlucky" 10_alsa or loading of kernel modules might not have been finished when
X is already running .


But I suspect the shell option of fluidsynth .

Once FluidSynth is running, it reads commands
from the stdin

-i, --no-shell
Don't read commands from the shell [default = yes]

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#14 Post by starhawk »

Added the -i, didn't fix :(

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#15 Post by Karl Godt »

Have compiled v1.1.5 - had to disable jack for jack_free missing in libjack*

This is what I get in terminal :

bash-3.00# fluidsynth -i -a alsa /root/Downloads/test/usr/share/sounds/sf2/FluidR3_GS.sf2
FluidSynth version 1.1.5
Copyright (C) 2000-2011 Peter Hanappe and others.
Distributed under the LGPL license.
SoundFont(R) is a registered trademark of E-mu Systems, Inc.

ALSA lib pcm.c:2211:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2211:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2211:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
fluidsynth: warning: No preset found on channel 0 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 1 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 2 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 3 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 4 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 5 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 6 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 7 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 8 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 9 [bank=128 prog=0]
fluidsynth: warning: No preset found on channel 10 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 11 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 12 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 13 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 14 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 15 [bank=0 prog=0]
fluidsynth: warning: Requested a period size of 64, got 940 instead
fluidsynth: warning: Requested 16 periods, got 8 instead
bash-3.00#



bash-3.00# ps | grep fluid
2034 root 1:42 /usr/local/bin/fluidsynth
12300 root 0:00 man fluidsynth

Seems to run though ....

Just don't know what it is supposed to do
and what the soundfont does .

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#16 Post by starhawk »

That looks about like what I have.

It's for playing MIDI music. MIDI is encoded as a set of instrument-note pairings -- what those instruments and notes actually sound like is left to other software -- the player, and more specifically, the soundfont. That soundfont (*.sf2 file) contains all of the MIDI sounds. Fluidsynth plays the role of a synthesizer, enabling the media player (in this case, Audacious) to output sound to the speakers.

MIDI is a rather old format, but I have a few that actually sound pretty good. (MIDI is well known for the really bad stuff, which is unfortunate -- with a little effort it can come out quite nice...) It hails from the era of floppy disks and 14.4k modems.

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#17 Post by Karl Godt »

So fluidsynth is a sound server listening on port localhost:9800 ?

Never used audacity ..

Are there any other known programs that use such soundfont server like aqualung or gxine or mhwaveedit ?

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#18 Post by starhawk »

AFAIK, Fluidsynth is not a networked anything. Server or client. It is a synthesizer.

Audacious hands note/instrument (eg, C#/piano or D/guitar) pairs to Fluidsynth. Fluidsynth matches those up with corresponding sounds in a soundfont. Fluidsynth returns the sounds to Audacious, which pipes out to a speaker set.

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#19 Post by starhawk »

Still stumped on this...

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#20 Post by Karl Godt »

I have no midi cards -nor any instruments to attach to MIDI cards .

I had few reads about MIDI and they were from kernel 2.4 times .

Don't know anything further after reading ,
except that /dev/midi should exist as link to /dev/midi0[0-4] char device file .


About the port :

bash-3.00# fluidsynth
...

Type 'help' for help topics.

> help

> settings
shell.port 9800


More I cannot decipher from the help or manual page .

To me it seems that it needs a controlling terminal ,
because the -i option is not working correctly or should work for other purposes .

Post Reply