LinuxQuestions.org
Review your favorite Linux distribution.
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 12-15-2006, 04:31 PM   #1
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
nautilus scripting - shh-cd-record.ksh


hi, i wish this used a gdialog progress bar instead of an infobox:


Code:
#!/bin/bash

# shh-cd-record-v0.1.ksh
# uses cdrecord to create cd. 
#  if the first file is a wav it will create an audio cd
#  else it'll make an iso then make a data cd using that iso. 
# depends: cdrecord, mkisofs, gdialog
# this software can be distributed or modified as needed - season to
taste.
# schneidz
# 12.05.2006
 
pwd=`echo $NAUTILUS_SCRIPT_CURRENT_URI | sed 's/file\:\/\///'`
cd $pwd
 
if [ `file -bi $1 | awk '{print $2}'` = audio/x-wav ]
then
 gdialog --infobox "making audio cd" 200 200
 sudo cdrecord dev=0,1,0 -v -dao -useinfo -text $@ speed=6 -eject 
 gdialog --infobox "audio cd complete" 200 200
else
 gdialog --infobox "making iso file" 200 200
 mkisofs -r -o shh-cd.iso $@ 
 gdialog --infobox "iso file complete\n starting cdrecord..." 200 200
 sudo cdrecord dev=0,1,0 -v shh-cd.iso speed=6 -eject 
 gdialog --infobox "data cd complete" 200 200
 rm shh-cd.iso
fi
 
Old 12-15-2006, 05:00 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Please post your thread once and in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread should be closed because it is a duplicate of http://www.linuxquestions.org/questi...d.php?t=510861.
 
Old 12-15-2006, 05:03 PM   #3
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Original Poster
Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
sorry, the three i posted today are similar but they are for 3 differnt scripts.

maybe i should've put them in the same post ?
 
Old 12-15-2006, 05:14 PM   #4
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
I don't see the problem with this script...?
 
Old 12-15-2006, 05:35 PM   #5
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Original Poster
Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
sorry, i didnt describe these posts very well.

the script does run fine but my wishlist includes having use a 'gdialog --guage' instead of an infobox so that it is possible to see how much it has done at any given time.

does anyone know the proper way to re-direct the output of cdrecord to create and update the 'gdialog --guage'?

thanks,
 
Old 12-15-2006, 09:53 PM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
does anyone know the proper way to re-direct the output of cdrecord to create and update the 'gdialog --guage'?
The "problem" with --gauge is you need to find a way to return a percentage, as in:
Code:
run() { i=0; while [ $i -le 100 ]; do i=$[${i}+10]; echo $i; [ $i -eq 100 ] && pkill -KILL -f $procname \
|| sleep 1s; done | doexec /usr/bin/gdialog $procname --backtitle "ripping-cd bak" --title "ripping-\
cd" --gauge "dvd-rip $currentfile" 8 60 0; }
]$ procname=`/bin/date +%s`; run
but it is not useful in situations where you can not measure a duration.

Maybe you can extract from info like "Track 01: 2 of 619 MB written", something like
Code:
max=700; output 2>/dev/null| grep ^Track | while read string; do 
array=(${string}); fill=${array[2]}; max=${array[4]}; 
prc=`echo "scale=2;${fill}/${max}*100"|bc -l`; echo ${prc//.*/}
done
I think, YMMV(VM).


maybe i should've put them in the same post ?
IMHO you should have.
 
Old 12-15-2006, 10:00 PM   #7
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
What you could do is, instead of using the "gdialog --gauge", just raise the cdrecord verbosity by two ("cdrecord -vv ..."), and let that be the gauge, then use the "gdialog" to mark that the burning process is complete.

It's not pretty, but it's the easiest way to get a gauge onscreen.
 
Old 12-15-2006, 11:22 PM   #8
J.W.
LQ Veteran
 
Registered: Mar 2003
Location: Boise, ID
Distribution: Mint
Posts: 6,642

Rep: Reputation: 87
Please post your question in only one forum

Last edited by J.W.; 12-15-2006 at 11:23 PM.
 
Old 12-19-2006, 02:00 PM   #9
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Original Poster
Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
the problem with cdrecord (and also with transcade i think) is that it sends its output to file discriptor 2.
is that standard even if it isn't reporting any errors.
either way i haven't had any luck grep-ing out any useful information like current track or estimated file size. (either because it doesn't flush each line or because it delineates lines with an ascii-13 - cr, rather than an ascii-10 - nl)

does anyone have any experience re-directing the output of these two programs ?

thanks,

Last edited by schneidz; 12-19-2006 at 02:06 PM.
 
  


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
nautilus scripting - shh-tc.ksh schneidz Programming 1 03-05-2007 11:06 PM
nautilus scripting - shh-cd-rip schneidz Programming 0 12-15-2006 04:23 PM
KSH and SCO Shell Scripting mpgram Programming 3 12-29-2005 12:24 PM
Three ksh scripting questions liguorir Linux - Software 2 10-22-2005 12:40 PM
some ksh scripting nabil Programming 1 03-03-2002 10:34 PM

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

All times are GMT -5. The time now is 07:53 PM.

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