rxvt -e and/or Xdialog TailBox to catch stdout. ( Solved )

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

rxvt -e and/or Xdialog TailBox to catch stdout. ( Solved )

#1 Post by sunburnt »

I`m trying to get Xdialog`s TailBox to work, and I can`t even get rxvt to work.
This utility runs ldd-recursive to get exec`s deps outputting to TailBox or rxvt.

Working solution:
File name: ldd-gui

Code: Select all

#!/bin/sh
#########	GUI select exec. file, run ldd and display the output.

libX="X11 Xau Xdamage Xdmcp Xext Xfixes Xxf86vm xcb"

libEX="linux asound libc libdl libdrm GL\. GLU\. freetype gcc_s\
libm librt pthread libtiff stdc++ libz"

fselP=/SqApp/mnt		# file select path

exePF=`Xdialog --stdout --title " Select an Executable." --fselect $fselP 0 0`
[ $? -gt 0 ]&& exit

echo '' > /tmp/ldd.lst
msg='Exclusive Dependency List.'

Xdialog --title " LDD Recursive" --tailbox /tmp/ldd.lst 32 64 &

L=`echo "$libEX $libX" |tr '[:space:]' '\n'`

ldd-recursive.pl $exePF |while read D
do
	[ ! `echo "$L" |grep $D` ]&& L=`echo -e "$L\x0a$D"` && echo $D >> /tmp/ldd.lst
done
rm /tmp/ldd.lst
Last edited by sunburnt on Thu 31 May 2012, 04:36, edited 4 times in total.

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#2 Post by jamesbond »

This works. output_log here represents your "ldd-recursive".

Code: Select all

#!/bin/sh
output_log() {
	while true; do 
		sleep 1
		count=$((count + 1))
		echo $count >> /tmp/countme
	done
}

### main
count=0
output_log &
XPID=$!
Xdialog --tailbox /tmp/countme 0 0
kill $XPID
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#3 Post by sunburnt »

Hello again jamesB; I tried your script and got the same error that I got.

Code: Select all

sh-4.1# /tmp/jb
Xdialog: can't open /tmp/countme
Strangely the while loop doesn`t write to the file until the loop`s done.
This of course explains why the TailBox can`t find the file.
I`m baffled as to why each loop the code isn`t written to the file.
It would be nice if the TailBox scrolled the info like it`s supposed to.
But I seem to recall having this problem years ago and gave up on the TailBox.

I revised it and this works ( sort of...):

Code: Select all

#!/bin/sh
#########	GUI to run ldd on app. exec.


libEX="linux|asound|libc|libdl|libdrm|freetype|gcc_s|libm|librt|pthread|libtiff|stdc++|libz|\
X11|Xau|Xdamage|Xdmcp|Xext|Xfixes|Xxf86vm|xcb"

fselP=/SqApp/mnt


exePF=`Xdialog --stdout --title " Select an Executable." --fselect $fselP 0 0`
[ $? -gt 0 ]&& exit

exeF=`basename $exePF`
depPF=/tmp/$exeF.dep
rm -f $depPF

ldd-recursive.pl $exePF |egrep -v "($libEX)" |while read D
do
	[ ! `echo "$L" |grep $D` ]&& L="$L\x0a$D" && echo "$D" >> $depPF
done &

echo -e "\n### Getting dependencies for $exeF\n"
echo -n "##> "
until [ -e $depPF ] ;do sleep 3 ;echo -n "X" ;sleep 3 ;echo -n "O" ;done
echo -e '\n### DONE\n'
Xdialog --title " LDD GUI" --backtitle "Dependency List." --tailbox $depPF 32 80
.
### The other thing is rxvt, it doesn`t want to run the long ldd command... Damn!!!
.

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#4 Post by jamesbond »

sunburnt wrote:Hello again jamesB; I tried your script and got the same error that I got.

Code: Select all

sh-4.1# /tmp/jb
Xdialog: can't open /tmp/countme
That is because I was silly. I tried the example twice - once manually and once after I wrote the script. It worked because /tmp/countme was already created during my "manual" experiment.

This is the updated example - notice the "sleep 2" to give time for output_log to run and create the output file ... you could of course create a simple wait loop to test that /tmp/countme already exist before starting tail.

Code: Select all

#!/bin/sh
output_log() {
	while true; do 
		sleep 1
		count=$((count + 1))
		echo $count >> /tmp/countme
	done
}

### main
count=0
output_log &
XPID=$!
sleep 2
Xdialog --tailbox /tmp/countme 0 0
kill $XPID
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#5 Post by jamesbond »

sunburnt wrote: ### The other thing is rxvt, it doesn`t want to run the long ldd command... Damn!!!
.
Apparently rxvt (at least urxvt - that's what I have here) can only execute one command, so the example in your first post will not work directly. You need to call shell and ask shell to execute there rest of your commands, pipe and everything.

This works.

Code: Select all

 rxvt -e /bin/sh -c "echo haha | sed 's/haha/hoho/'; read"
Note the absence of -hold and the presence of "read" at the end of the script ...

IMO, this is much better than xterm, gnome-term and other terms that executes everything as one quoted string --- makes is super-hard to write a pipe like the above ....
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#6 Post by sunburnt »

Now that works Great !!! Thanks JB. Seeing the info scroll is better than waiting.

I wonder what the deal is with the while loop? Just more odd shell behavior.

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#7 Post by jamesbond »

sunburnt wrote:Now that works Great !!! Thanks JB. Seeing the info scroll is better than waiting.
Glad that it works. Looking forward to see your work. I've been following your idea of mounted-but-not-unioned squashfs, but I haven't gotten a clear picture of how to implement that seamlessly yet.
I wonder what the deal is with the while loop? Just more odd shell behavior.
Which is?
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#8 Post by sunburnt »

Nothing seems to be seamless in Linux, it`s just designed that way.
Unix was made for main frames and for admin`s to run and it works very well like that.
But for a desktop O.S. and all the app. install/uninstall it lacks a bit.
The biggest problem is that apps. scatter files all over the dir. tree.

I`ve said before that Linux needs to be organized into read-only and read-write dirs.
Read-only dirs. can then be in Squash files, and read-write dirs. on partitions.

# The trick for SqApps:
1) The app. finding all it`s deps. when all it`s files are in a nonstandard location.
Tiny Core Linux solves this with masses of links pointing into the Squash files.
It also has SCM Squash files that are setup to run without lots of links.
It does this by compiling them that way, but also uses binary files too.
There are ways to edit ELF binaries to change the paths in them.
Then the deps. can be in nonstandard locations and still be found.

2) How to write to config. files that are in a Squash file.
The only way to do this I can see is the config. file is a link pointing to the real
config. file in /usr/etc that was copied from the SqApp file when it`s loaded.
Icons are copied also so the desktop and menus can access them.
I think Tiny Core mounts ALL SCM files at boot to access the icons,
but it still has to copy the config. files.
I don`t like the kernel managing lots of mounts if the apps. aren`t used.

I`m running all the options through my brain. If you have suggestions...

Thanks again for all the help. Terry B.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#9 Post by sunburnt »

After a nights sleep I found out what I was doing wrong.

A working solution is in the first post at the top.
.

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#10 Post by RSH »

sunburnt wrote:Thanks again for all the help. Terry B.
Hmm...

Terry B. Terry B. Terry B.....

Where did i heard that name before?

Got it! You are Terry Bozzio! The world's best drummer with the world's biggest drum!

Greetings from germany, from another drummer! :lol:
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#11 Post by sunburnt »

Hi RSH, how`s it been? It`s been a little while since we`ve talked.
What have you been working on lately? Come on, tell us your secrets!

Not doing much drumming so I moved into that big one, lots of space... :P

Post Reply