Results 1 to 4 of 4
Hello,
I'm trying to write a simple script to back up all jpeg and png files from removable media in a graphical way using zenity as a bit of an ...
- 02-08-2009 #1Just Joined!
- Join Date
- Feb 2009
- Posts
- 1
need help with simple zenity script
Hello,
I'm trying to write a simple script to back up all jpeg and png files from removable media in a graphical way using zenity as a bit of an exercise I've set myself.
I've reached a bit of a brick wall and can't understand the result I'm getting from a command so wsa hoping someone could help.
Cutting out superfluous stuff (like titles, text etc...) what I have in a nutshell is this;
Now when I try to use find on the output in the next line like so;Code:#!/bin/bash # Medlist=`ls -1 -I cdrom0 /media | while read File; do echo "FALSE $File"; done` # ans1=$(zenity --list --title="Select Storage Device(s)" --text="Here is the list of removable storage devices." --checklist --multiple --separator="," --column " " --column "Removable Storage" $Medlist)
I get an error saying find: file '/media/{disk,disk-1,etc}' not found.Code:ans2=`find /media/{$ans1} -name "*.jpg" -or -name "*.png"` # echo $ans2
If I enter the find command directly into the shell however, it works fine. I can't see why it isn't working as part of the script as the syntax in the error message seems fine.
Any ideas?
-JimDog*-
- 03-05-2009 #2Just Joined!
- Join Date
- Oct 2004
- Posts
- 62
Hi,
I didn't replay to your request to leave space to the Linux gurus and above all because I hadn't
understood your problem.
After 3 weeks I see that you still have 0 replays... I hope that you, in the meantime, have solved
your problem by yourself!
.
If it's not the case... we can solve it ... starting however on more infos.
As I get it, you need a script to backup jpg & png files from removable media (CD. DVD, floppy,
pendrives or USB External drive)... what is zenity for?
Try before to solve your problem w/out zenity (which at max here has visualization purposes....)
To test zenity you should test the single dialogs alone...
Bye.
- 03-06-2009 #3Linux User
- Join Date
- May 2008
- Location
- NYC, moved from KS & MO
- Posts
- 251
It would be nice if variable expansion works in the scenario you describe but unfortunately it doesn't. My work-around is not that pretty but it should work (basically it just expands the $ans1 variable "manually").
Code:OLD_IFS=$IFS IFS=',' target='' for d in $ans1; do target="/media/$d $target"; done IFS=$OLD_IF ans2=`find $target -name "*.jpg" -or -name "*.png"` # echo $ans2
- 03-06-2009 #4Linux User
- Join Date
- May 2008
- Location
- NYC, moved from KS & MO
- Posts
- 251
Well it seems my conclusion was too early. I've got the solution for you:
PS: I learned the trick from [ Internal Commands and Builtins , section eval ]Code:ans2=`eval find /media/{$ans1} -name "*.jpg" -or -name "*.png"` # ans2=`echo $ans2`


Reply With Quote