LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-06-2016, 01:36 AM   #1
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622
Blog Entries: 40

Rep: Reputation: Disabled
Zenity --text-info shows more than I would hope for


Edit: the call to 'echo' was missing in the script, below. (sorry)

Good morning,

To demonstrate the use of Zenity, I came up with this script-example
Code:
 
#!/bin/dash
IP=$(zenity --title "traceroute" --entry --text "IP or domain")

if [ "$IP" != '' ]
then
 	echo $(traceroute $IP) | zenity --text-info
#	xterm -e "traceroute $IP"
fi
The output is not formatted, as I do not yet care. The content however, is worrying me. After the first line from traceroute, the content of the current dircetory, where I put the script, is shown three times, then the remainder from traceroute. Screen shot: http://pix.toile-libre.org/upload/img/1454742731.png

A call to traceroute in a terminal-emulator looks normal, and you can replace traceroute by whois in the above script to get the same ugly result, but at least no surprises. If there is something wrong with traceroute, I wonder why it is becoming visible only when using redirection with $() ...

Have a nice week-end, all. And if someone knows something that I have not yet seen or should modify in my call to traceroute and zenity, please tell me.

Cheerio,

Michael

Last edited by Michael Uplawski; 02-06-2016 at 06:30 AM. Reason: echo was missing.
 
Old 02-06-2016, 02:13 AM   #2
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622

Original Poster
Blog Entries: 40

Rep: Reputation: Disabled
Work-around

Even if there is no explicit question in my original post, above, part of the answer may be to write the output to a temporary file and use the --filename parameter of Zenity. This is not a solution and does not help to explain the strange behaviour of the original script. But it works and even corrects the formatting:

Code:
#!/bin/dash
IP=$(zenity --title "traceroute" --entry --text "IP or domain")

if [ "$IP" != '' ]
then
	tfile=`mktemp`

#	 echo "writing to $tfile"

	traceroute "$IP" > "$tfile"
 	zenity --text-info --filename="$tfile"
	rm -f "$tfile"

#	echo $(traceroute $IP) | zenity --text-info
#	xterm -e "traceroute $IP"
fi

Last edited by Michael Uplawski; 02-06-2016 at 02:21 AM. Reason: 1 echo was missing. And I am dumb.
 
Old 02-06-2016, 02:32 AM   #3
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622

Original Poster
Blog Entries: 40

Rep: Reputation: Disabled
YAD does like zenity

Just for completeness. Replacing zenity by yad, I get the same additional content in the text-info dialog. Only the formatting is different, but that does not matter. I recommend to either pipe the traceroute-output directly to Zenity/Yad or to read from a temporary file, as in the example, above.

... but still, I would like to know what's strange about echo $(traceroute google.com).
 
Old 02-06-2016, 06:35 AM   #4
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622

Original Poster
Blog Entries: 40

Rep: Reputation: Disabled
The solution:
"$(traceroute [ip or domain]"
Explication:
As traceroute produces asterisks, these are interpreted as the wild-card character which will be applied to the content of the current directory and match all the file-system-objects in reach. Quote-marks quote the asterisks and just hand them over as String components to the receiving end (a variable, another command or STDOUT).

I do not remember if I once had known this. Traceroute is innocent.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
netstat -anp shows lot of info GNU/Linux Slackware 1 11-11-2013 06:48 AM
LXer: GLAMOR'ized Radeon Driver Shows Hope Over EXA LXer Syndicated Linux News 0 10-03-2013 11:41 AM
LXer: VIA Shows Us Next-Gen Hardware Results, Info LXer Syndicated Linux News 0 01-26-2012 06:20 PM
Extract certain text info from text file xmrkite Linux - Software 30 02-26-2008 11:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration