this post was submitted on 18 Aug 2024
19 points (100.0% liked)
linux4noobs
1356 readers
1 users here now
linux4noobs
Noob Friendly, Expert Enabling
Whether you're a seasoned pro or the noobiest of noobs, you've found the right place for Linux support and information. With a dedication to supporting free and open source software, this community aims to ensure Linux fits your needs and works for you. From troubleshooting to tutorials, practical tips, news and more, all aspects of Linux are warmly welcomed. Join a community of like-minded enthusiasts and professionals driving Linux's ongoing evolution.
Seeking Support?
- Mention your Linux distro and relevant system details.
- Describe what you've tried so far.
- Share your solution even if you found it yourself.
- Do not delete your post. This allows other people to see possible solutions if they have a similar problem.
- Properly format any scripts, code, logs, or error messages.
- Be mindful to omit any sensitive information such as usernames, passwords, IP addresses, etc.
Community Rules
- Keep discussions respectful and amiable. This community is a space where individuals may freely inquire, exchange thoughts, express viewpoints, and extend help without encountering belittlement. We were all a noob at one point. Differing opinions and ideas is a normal part of discourse, but it must remain civil. Offenders will be warned and/or removed.
- Posts must be Linux oriented
- Spam or affiliate links will not be tolerated.
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Ahhh, so apparently in the man page for cdrecord it mentions it needs to be ran as root since it uses "real time scheduling" to write. So even if you have proper permissions to use the cd burner, you still need root to run it. I made a bad assumption that you were having to use root since you didn't have permissions as your use to write to it.
If you don't need to parse the output of "cdrecord -checkdrive" then setting that var is pretty trivial.
CDROM=$(cdrecord -checkdrive)
If that outputs more than just the string you need, that gets a little headachey. Grep/awk/sed/sort/uniq/regex are all very powerful and esoteric.
That being said, the man page also mentions that most users will not have to specify "dev" at all as it should figure it out automatically. So you might be ok with axing the "dev" part of the command instead of feeding it the device path.
AH! Oh well no harm no foul, I can run my script as root, I trust me!
Cdrecord -checkdrive does output a whole mess of stuff:
And the only part I need is the part that says /dev/sr0/.
I will try deleting the /dev/ part entirely though and see what happens (probably tomorrow evening). If it works that'll be perfect. Thanks!
Edit: No dice, dev=/dev/sr0 is needed in my case.
This is a very goofy workaround for you that doesn't actually check what the device is. Only checks if /dev/sr0 exists and if yes, use that if no then use /dev/sr1. Better solution below this block. But leaving it because I kind of like it's jankiness.
Not elegant and a little janky but works.
This will work better. We are taking the output of -checkdrive, searching for "Detected" and sending that to awk. We are telling awk to split that line into columns based on this character ":" and to print the second column. That should give you an output of " /dev/sr0" with a space in front.
That should work. But if you absolutely must kill the whitespace for some reason we can add trim to the end like so
There might be a more elegant solution by using the output of "cdrecord -scanbus" instead. No clue though since I don't have the hardware to verify from here. Hope that helps!
This looks like it'll work perfectly, thank you! When I get home from work I'll play around with -scanbus and see if it works out first, then I'll try with the space and if no dice I'll try without the space!
I'm also going to try k3b and see how that works as another poster was saying, but at this point I think I prefer the script lmao!