paul Posted December 19, 2003 Report 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? Quote Link to comment Share on other sites More sharing options...
paul Posted December 20, 2003 Author Report 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); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.