Rockbox.org home
Downloads
Release release
Dev builds dev builds
Extras extras
themes themes
Documentation
Manual manual
Wiki wiki
Device Status device status
Support
Forums forums
Mailing lists mailing lists
IRC IRC
Development
Bugs bugs
Patches patches
Dev Guide dev guide
Search



Donate

Rockbox Technical Forums


Login with username, password and session length
Home Help Search Staff List Login Register
News:

Welcome to the Rockbox Technical Forums!

+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  ipodpatcher scripting question.
« previous next »
  • Print
Pages: [1]

Author Topic: ipodpatcher scripting question.  (Read 3674 times)

Offline jackbnymbl

  • Member
  • *
  • Posts: 5
ipodpatcher scripting question.
« on: July 05, 2007, 10:29:45 AM »
I'm writing a script which requires the use of ipodpatcher, and I'm kindof a scripting n00b, so I was wondering if anyone could tell me how to get just the device location from "ipodpatcher --scan", e.g. "/dev/sda" and input it to a variable?

It would also be nice if it could output the iPod type to a variable, e.g. "1st generation iPod Nano"
« Last Edit: July 05, 2007, 10:34:23 AM by jackbnymbl »
Logged

Offline bluebrother

  • Developer
  • Member
  • *
  • Posts: 3421
  • creature
Re: ipodpatcher scripting question.
« Reply #1 on: July 05, 2007, 01:17:12 PM »
redirect the output of ipodpatcher and cut everything you don't need -- perl will do, as various other ways like using sed / awk.
Logged
Rockbox Utility development binaries (updated infrequently) · How to ask questions the smart way · We do not estimate timeframes.

Offline jackbnymbl

  • Member
  • *
  • Posts: 5
Re: ipodpatcher scripting question.
« Reply #2 on: July 05, 2007, 09:57:29 PM »
I looked at the man pages for sed and awk, but I'm still blank (like I said, I'm kindof a n00b here). Maybe someone can give me some scripting help?
Logged

Offline bluebrother

  • Developer
  • Member
  • *
  • Posts: 3421
  • creature
Re: ipodpatcher scripting question.
« Reply #3 on: July 06, 2007, 03:03:02 AM »
try something like this:
./ipodpatcher -l 2>/dev/null | sed -e '/Ipod\ model/!d;s/^.*\:\ //'
./ipodpatcher -l 2>/dev/null | sed -e '/Ipod\ found/!d;s/^.*\///'
Logged
Rockbox Utility development binaries (updated infrequently) · How to ask questions the smart way · We do not estimate timeframes.

Offline jackbnymbl

  • Member
  • *
  • Posts: 5
Re: ipodpatcher scripting question.
« Reply #4 on: July 06, 2007, 10:02:41 AM »
Thanks for the help, but now I just can't figure out how to get the output into a variable. Also, is there any chance to make the first command not display "winpod"/"macpod" and the second one include /dev/? Thanks for your help though.
Logged

Offline bluebrother

  • Developer
  • Member
  • *
  • Posts: 3421
  • creature
Re: ipodpatcher scripting question.
« Reply #5 on: July 06, 2007, 10:15:30 AM »
well, you can redirect the command output and simply prepend /dev/
DEVICE=/dev/`./ipodpatcher -l 2>/dev/null | sed -e '/Ipod\ found/!d;s/^.*\///'`

As a different solution you could adjust the replacement to not match the /dev/ prefix. You can strip the "winpod" part similar: just replace the part in parentensis with an empty string. Check the manual for sed for details. Another great resource for beginning is the book "Linux in a nutshell".

Anyway, this is getting quite off topic here ...
Logged
Rockbox Utility development binaries (updated infrequently) · How to ask questions the smart way · We do not estimate timeframes.

Offline jackbnymbl

  • Member
  • *
  • Posts: 5
Re: ipodpatcher scripting question.
« Reply #6 on: July 06, 2007, 12:36:04 PM »
That works perfectly (and I figured out how to get rid of winpod/macpod)
Thanks for all the help! Is there any way to get it to tell me what size the iPod is? (rounded to the nearest GB)
« Last Edit: July 06, 2007, 12:38:22 PM by jackbnymbl »
Logged

Offline bluebrother

  • Developer
  • Member
  • *
  • Posts: 3421
  • creature
Re: ipodpatcher scripting question.
« Reply #7 on: July 06, 2007, 03:35:13 PM »
well, you could check the size of the disk using fdisk -l

But we're getting really off topic now ... this is about scripting, not Rockbox any more ;-)
Logged
Rockbox Utility development binaries (updated infrequently) · How to ask questions the smart way · We do not estimate timeframes.

Offline jackbnymbl

  • Member
  • *
  • Posts: 5
Re: ipodpatcher scripting question.
« Reply #8 on: July 06, 2007, 04:44:25 PM »
true...
In that case, my on-topic suggestion is to add an off-topic forum!
Logged

Offline scorche

  • Administrator
  • Member
  • *
  • Posts: 666
Re: ipodpatcher scripting question.
« Reply #9 on: July 08, 2007, 04:39:13 PM »
Quote from: jackbnymbl on July 06, 2007, 04:44:25 PM
true...
In that case, my on-topic suggestion is to add an off-topic forum!

No.  ;D

(This has been discussed before and shot down, as this is a technical forum and not a social forum.  A technical forum needs no off-topic forum.)
Logged

  • Print
Pages: [1]
« previous next »
+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  ipodpatcher scripting question.
 

  • SMF 2.0.17 | SMF © 2019, Simple Machines
  • Rockbox Privacy Policy
  • XHTML
  • RSS
  • WAP2

Page created in 0.075 seconds with 15 queries.