LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-27-2007, 06:22 PM   #1
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Rep: Reputation: 255Reputation: 255Reputation: 255
stupid " & ' question


Quote:
scrot "/home/xeratul/shots/$(gdialog --title 'Screenshot' --inputbox 'Output filename:' 100 100).png"
this is absolutely not working and not makign its screenshot ...

I am fighting with the ' and ". It is very stupid but It cannot work. Why ?

Thank you
 
Old 05-27-2007, 07:39 PM   #2
kstan
Member
 
Registered: Sep 2004
Location: Malaysia, Johor
Distribution: Dual boot MacOS X/Ubuntu 9.10
Posts: 851

Rep: Reputation: 31
try this
scrot "/home/xeratul/shots/$(gdialog --title \'Screenshot\' --inputbox \'Output filename:\' 100 100).png"
or
scrot /home/xeratul/shots/$(gdialog --title 'Screenshot' --inputbox 'Output filename:' 100 100).png
if still doesn't work, try to issue filename without a space.

Regards,
Ks
 
Old 05-27-2007, 09:49 PM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
The gdialog part of the command is OK. The problem is that gdialog returns its value on stderr instead of stdout.

Try the command by itself and then with 2&>/dev/null. During the latter, there is no output.
Code:
gdialog --title 'Screenshot' --inputbox 'Output filename:' 100 100
sample2
gdialog --title 'Screenshot' --inputbox 'Output filename:' 100 100 2&>/dev/null
However, this could be due to gdialog being a wrapper command for zenity. When I went to install gdialog, I was able to install zenity.

That said, I was able to do this:
Code:
filename=$(zenity --title 'Screenshot' --entry 'Output filename:' 100 100 | cat).png
scrot "$filename"
and this:
scrot $(gdialog --title 'Screenshot' --inputbox 'Output filename:' 100 100 2&>/dev/stdout).png

Last edited by jschiwal; 05-27-2007 at 10:08 PM.
 
Old 05-28-2007, 01:11 AM   #4
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by jschiwal
The gdialog part of the command is OK. The problem is that gdialog returns its value on stderr instead of stdout.

Try the command by itself and then with 2&>/dev/null. During the latter, there is no output.
Code:
gdialog --title 'Screenshot' --inputbox 'Output filename:' 100 100
sample2
gdialog --title 'Screenshot' --inputbox 'Output filename:' 100 100 2&>/dev/null
However, this could be due to gdialog being a wrapper command for zenity. When I went to install gdialog, I was able to install zenity.

That said, I was able to do this:
Code:
filename=$(zenity --title 'Screenshot' --entry 'Output filename:' 100 100 | cat).png
scrot "$filename"
and this:
scrot $(gdialog --title 'Screenshot' --inputbox 'Output filename:' 100 100 2&>/dev/stdout).png
Thank you !

Indeed, the single function:
Code:
scrot "screenshots/$(gdialog --title 'Screenshot' --inputbox 'Output filename:' 100 100 2&>/dev/stdout).png"
works.

I looked on:
http://en.wikipedia.org/wiki/Image:S...ms-notitle.svg
http://www.phim.unibe.ch/comp_doc/c_.../stdfiles.html
http://www.faqs.org/faqs/unix-faq/fa...section-9.html
to understand how to find out if a program is stdout.

I am not sure to understand why it is stderr (reason) and how to detect the output whether they are stdout only or stderr...

No so easy all these stderr/stdout ...
 
Old 05-28-2007, 07:16 AM   #5
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Soo, I tried to use the /dev/null stuffs

I have a folder containing 10 files.

Why this is not working then ... ?

Code:
 for each in "$(ls -1)" ;   do   beep > /dev/null      ; sleep 3  ; done
Code:
 for each in "$(ls -1)" ;   do   eog $each > /dev/null      ; sleep 3  ; done
are both not working

That s not easy to learn sh, it s not like basic. Really complex guy.

Thank you greatly if you find out the problem ?!

==
is working:
Code:
  for each in "$(ls -1)" ;   do   ls -la $each    ; sleep 3  ; done

===
your trick, let open only one single file :-( (at least):
Code:
 for each in "$(ls -1)" ;   do   eog $each&  &>/dev/stdout   ; done

Last edited by Xeratul; 05-28-2007 at 07:21 AM.
 
Old 05-28-2007, 07:42 AM   #6
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
I found the error :

for FILE in $(ls); do [COMMAND]; done

This ; is very importnat apparently

==
howto:
http://penguinpetes.com/b2evo/index....&c=1&tb=1&pb=1.
 
Old 05-28-2007, 07:45 AM   #7
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Very interesting:

why ?

this works:
Code:
for FILE in $(ls); do echo $FILE ; beep ; done
and this not
Code:
for FILE in "$(ls)"; do echo $FILE ; beep ; done
because the "" will consider only one file
damn

Last edited by Xeratul; 05-28-2007 at 07:46 AM.
 
Old 05-28-2007, 08:45 AM   #8
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Quote:
Originally Posted by Xeratul
Very interesting:

why ?

this works:
Code:
for FILE in $(ls); do echo $FILE ; beep ; done
and this not
Code:
for FILE in "$(ls)"; do echo $FILE ; beep ; done
because the "" will consider only one file
damn
You don't need the ls command:
for file in *
will do fine. You don't put quotes around the term when using for, but when you reference the variable, it is a good idea if any of the filenames contain embedded whitespace
for file in *; do
dosomething "$file"
done

---

I don't understand why gdialog returns the output on stderr. The manpage says differently. However in my case, I don't actually have the gdialog command. Mine is a perl script wrapper which calls the zenity command.

In your script if you have zenity as well you could use
"zenity --file-selection" instead.
 
Old 05-29-2007, 01:56 PM   #9
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by jschiwal
You don't need the ls command:
for file in *
will do fine. You don't put quotes around the term when using for, but when you reference the variable, it is a good idea if any of the filenames contain embedded whitespace
for file in *; do
dosomething "$file"
done

---

I don't understand why gdialog returns the output on stderr. The manpage says differently. However in my case, I don't actually have the gdialog command. Mine is a perl script wrapper which calls the zenity command.

In your script if you have zenity as well you could use
"zenity --file-selection" instead.
a perl or python program or the xdialog would be maybe a better solution, that wouldnt call the gnome environment and would be lighter in terms of memory consumtion ... I guess, no ?

thank you for yoru help with this *
that solved indeed the \ problems with space !!
 
  


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
Yum & "Core Binaries" Question The00Dustin Linux - Software 2 09-26-2006 11:15 AM
Kinda stupid question - slackware & 64-bit processors mmarkvillanueva Slackware 14 10-26-2005 01:48 AM
Stupid, stupid question; I lost Klaptop. :( Surfrider Slackware 2 08-31-2005 09:12 PM
Stupid question about Windows & Linux zahadumy Linux - General 6 06-01-2005 11:04 AM
Very Stupid Question about Iptables & Portforwarding kemplej Linux - Networking 20 07-27-2004 02:37 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:49 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