SendMsgAndGet won't communicate with shell script

Hi,

I try to communicate over SendMsgAndGet with a shell script but it doesn’t work. With the perl ComExample it works.

Here’s my test code:
FvwmScript]Init
Begin
Set $pid = (GetPid)
Set $ComName = {ComExample-}$pid
Set $DATADIR = {/home/tf/}
Set $Bash = {/usr/bin/bash}

Do {Exec }$DATADIR{pipeout.sh }$ComName{ &}

End
:
:
Widget 1
Property
Type ItemDraw
Size 24 24
Position 32 104
Flags NoFocus NoReliefString Left
Main
Case message of
SingleClic :
Begin
Do {echo Play clicked}
Set $tmp = (SendMsgAndGet $ComName {Play} 0)
End
End[/code]

Bash script]#!/bin/bash

ComName=$1

inpipe=/home/tf/.fvwm-nightshade/.tmp-com-in-$1
outpipe=/home/tf/.fvwm-nightshade/.tmp-com-out-$1
echo $inpipe >> ~/.xsession-errors

trap “rm -f $inpipe” EXIT
trap “rm -f $outpipe” EXIT

if [[ ! -p $inpipe ]]; then
mkfifo $inpipe
fi

if [[ ! -p $outpipe ]]; then
mkfifo $outpipe
fi

while true
do
if read line <$inpipe; then
if [[ “$line” == ‘quit’ ]]; then
break
fi
echo $line >> ~/.xsession-errors
fi
done

echo “Reader exiting” >> ~/.xsession-errors

rm -f $inpipe
rm -f $outpipe[/code]

As I send over another terminal a command to the pipe like echo testem > /home/tf/.fvwm-nightshade/.tmp-com-in-ComExample-10220 the “testem” occurs in .xsession-errors …

Any clue?

Thanks,
Thomas

Hello Thomas,

I think the line

Do {Exec }$DATADIR{pipeout.sh }$ComName{ &}

Should read

Do {Exec }$Bash{ } $DATADIR{pipeout.sh }$ComName{ &}

You also have to get rid of the lines which contain “:” after the init-section, these give an error.
Before the init-section you have to add the following lines otherwise you get an error setting up the window.

WindowTitle {FvwmScript-ComExample} WindowSize 360 360

Hi libernux,

thanks for reply :slight_smile:

First some adjustments:

I forgot to delete the line Set $Bash = {/usr/bin/bash} . ‘Exec’ do this for me.

The ‘:’ are only to show that here are some other code lines which doesn’t relevant for the problem. Sorry, my mistake :S

The same. I only posted the relevant parts of the script.

I have searched the last days the internet and found a description why SendMsgAndGet doesn’t work with shell scripts:http://www.mcnabbs.org/andrew/linux/pipemystery/
The problem is, that a pipe must open for SendMsgAndGet in non blocking mode. Else the shell script must first open the inpipe before SendMsgAndGet can send a message.

So I decided to use a perl script like ‘FvwmScript-ComExample.pl’ in /usr/share/fvwm to fix this issue.

Thanks again for trying to help,
Thomas