paul Posted December 19, 2003 Share Posted December 19, 2003 hi guys .. I've got an idea but my bash/sh skills are lacking so ... here's a run down of what I want the code to be like firstly a file called ~/.cdromstatus closed secondly the code bit this is NOT real code ... because I suck at writing bash scripts ... but maybe someone will understand what I am trying to achieve #!/bin/bash STATUS = file(~/.cdromstatus) if $STATUS == closed { $COMMAND = "eject /dev/cdrom" rm ~/.cdromstatus echo open > ~/.cdromstatus } if $STATUS == open { $COMMAND = eject -t /dev/cdrom" rm ~/.cdromstatus echo closed > ~/.cdromstatus } exec $COMMAND understand what am trying to do? Link to comment Share on other sites More sharing options...
paul Posted December 20, 2003 Author Share Posted December 20, 2003 ok figured how to do it myself ;) #!/usr/bin/php -q <?php $status_file = "/home/paul/.cdtray_status"; $cd_status = file($status_file); $cd_status = rtrim($cd_status[0]); $device = "/dev/cdrom"; function update_status($status, $status_file) { $out = fopen($status_file, "w"); fwrite($out, $status); fclose($out); } switch ($cd_status) { case "closed": update_status("open", $status_file); $command = "eject ".$device; break; case "open": update_status("closed", $status_file); $command = "eject -t ".$device; break; default: $command = "xmessage \"can't get cdrom status\""; } exec($command); ?> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now