Hey All! I've written a Bash script called `clock`, which is called by one of two symbolic links: `clock-in` and `clock-out`. This script is, effectively, a time-clock for tracking time spent on various projects for clients. This script generates a "time card" file, if one does not exist in my "$HOME/Timecards" folder, and/or appends to the "time card' file. The file name is the first parameter passed into my `clock` script. The second parameter is a note to be placed with either the clock-in or clock-out to give a little detail to the "time card".
Now, I'm trying to write a Perl script that will open a "time card" and process it to generate an invoice based on the information in the "time card" file. However, whenever I try to open any of the time card files in my Timecards folder, I get the error "Inappropriate ioctl for device". I've read other posts in this group, as well as many others, but have not found a solution to this error. I am pasting the code below for your review, to see if I've made some kind of odd mistake with the Perl syntax. I've got a lot of programming experience, but not much with Perl, so I'm just applying my knowledge of other languages to Perl and trying to learn the syntax as I go. Please forgive any conventions that I may have used that aren't common to Perl. Here's the code in question: ###################################################################### # Create a variable to hold the path to the TimeCard files. These # # should be located in a folder, under the user's home folder, called# # 'Timecards'. # ###################################################################### $TimeCardsPath = $ENV{'HOME'} . "/Timecards/"; ####################################################################### # Check for command-line arguments. If there are none, call exit() # # with the command-line usage error as a parameter. # ####################################################################### if ( !defined( $ARGV[0] ) ) { $ExitStatus = $EX_USAGE; ExitScript(); } else { # Let the user know that we are processing the filename that they passed # in to the script. Also, this shows the user that we are processing # TimeCards from a specific directory in their $HOME folder, according # to the Bash Environment Variable. print "Processing: $TimeCardsPath$ARGV[0]\n"; # Declare a variable to hole each line of the TimeCard file. $Line = ""; # Declare four variables to hold the introductory note, time in, time out # and closing note of the clock punch. $iNote = ""; $TimeIn = ""; $TimeOut = ""; $cNote = ""; # Now, we need to create a file handle to access the TimeCard file. open ( TIMECARD, $TimeCardsPath . $ARGV[0] ) || die $ExitStatus = $EX_NOINPUT; # Check to see if we were able to open the TimeCard file: if ( $ExitStatus = $EX_NOINPUT ) { # We need to let the user know that we were unable to open # the TimeCard and exit the script. print "Unable to open the file:\n"; print "\t$TimeCardsPath$ARGV[0]\n"; print "Please make sure that the file exists in the above path\n"; print "and that you have read access to the file.\n"; print "\nReturned Error:\n\t"; print "$!\n\n"; ExitScript(); } else { # Process the file and create the invoice. # Implement processing here. # Close the input file. close ( TIMECARD ); # Exit the script with normal termination status. exit ( $EX_OK ); } # End of invoice generation. } # End of command-line parameter check. sub ExitScript { if ( $ExitStatus == 64 ) { system ( 'clear' ); print "INVOICE GENERATOR v0.6\n"; print "~~~~~~~~~~~~~~~~~~~~~~\n"; print "PekinSOFT Systems\n"; print "Copyright(c) 2008\n"; print "\n"; print "\n"; print "USAGE: invoice {TimeCard Filename}\n"; print "\n"; print " TimeCard Filename\tName of the time card for which to have an invoice generated.\n"; print "\n"; } else { exit( $ExitStatus ); } # End of ExitStatus check. } # End of ExitScript() function. This code includes everything except my opening comments describing the script and the definition of my exit status codes, which are taken directly from `sysexits.h`. In my `die` statement, I'm setting the ExitStatus variable, which is not something that I see in examples of the `open` statement...I only see something like: `die "Error message"`, so I don't know if that's causing the problem or even if that is a legal statement. Here is the output that I'm getting when I run the script: Processing: /home/sean/Timecards/TimeCards Unable to open the file: /home/sean/Timecards/TimeCards Please make sure that the file exists in the above path and that you have read access to the file. Returned Error: Inappropriate ioctl for device As you can see in the output, the path is displaying correctly, so I assume that the path is also correct in the `open` statement. However, in the `open` statement, I am using the concatenation operator (.) instead of doing like it is in my `print` statements. Could this be causing the problem? Steps that I've taken: 1) Checked to make sure that I have no typos in my path and I don't. 2) Checked to make sure that the file exists and it does. 3) Checked to make sure that I have read access to the file and the Timecards folder, which I do because I created the folder and the file through my Bash script. 4) Made sure that I have no errors on my file system and I don't. Any and all help is much appreciated. My system is as follows, in case this information is useful to you to help me diagnose this error. Dell Dimension 3000 Intel Pentium IV 3.0 GHz 1 GB DDR-RAM 70 GB HDD nVidia GE Force FX-5500, 128 MB VRAM Slackware 12.0 `uname -a`: Linux {HOSTNAME} 2.6.21.5-smp #2 SMP Tue Jun 19 14:58:11 CDT 2007 i686 Intel(R) Pentium(R) 4 CPU 3.00GHz GenuineIntel GNU/Linux KDE 3.5.7 XOrg Server 1.4.0.90 Thank you very much for any and all assistance you are able to provide to help me figure this one out. Thankfully, this is just for me and not for a client. Cheers, Sean Carrick PekinSOFT Systems PekinSOFT at gmail dot com http://www.pekinsoft.net/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/