Hello,
I am creating / appending files using a variable as the input name. Eg. $USER.jpeg makes a file called rony.jpeg . I want to add 2 variables to the file name instead of one and make $USER-$DATE.jpeg (rony-23/03/11.jpeg). What is the correct syntax for it as I keep getting errors in the mv as well as rename command. Tried $USER_$DATE or $USER.$DATE etc but no result. Did look up google but it has complex sed scripts.
2011/3/23 Rony Bill gnulinuxist@gmail.com:
I am creating / appending files using a variable as the input name. Eg. $USER.jpeg makes a file called rony.jpeg . I want to add 2 variables to the file name instead of one and make $USER-$DATE.jpeg (rony-23/03/11.jpeg). What is the correct syntax for it as I keep getting errors in the mv as well as rename command. Tried $USER_$DATE or $USER.$DATE etc but no result. Did look up google but it has complex sed scripts.
Your $DATE appears to be misformatted - Linux (or for that matter, any Unix) cannot have filenames that contain the '/'. It is one of the two characters that are forbidden in filenames.
Apart from that, $USER-$DATE and $USER.$DATE both should work ($USER_$DATE will not). Please post actual script and its output for better debugging.
Binand
On Wed, Mar 23, 2011 at 6:39 PM, Binand Sethumadhavan binand@gmail.comwrote:
2011/3/23 Rony Bill gnulinuxist@gmail.com:
I am creating / appending files using a variable as the input name. Eg. $USER.jpeg makes a file called rony.jpeg . I want to add 2 variables to
the
file name instead of one and make $USER-$DATE.jpeg (rony-23/03/11.jpeg). What is the correct syntax for it as I keep getting errors in the mv as
well
as rename command. Tried $USER_$DATE or $USER.$DATE etc but no result.
Did
look up google but it has complex sed scripts.
Your $DATE appears to be misformatted - Linux (or for that matter, any Unix) cannot have filenames that contain the '/'. It is one of the two characters that are forbidden in filenames.
Apart from that, $USER-$DATE and $USER.$DATE both should work ($USER_$DATE will not). Please post actual script and its output for better debugging.
Yes you are right. The '/' in the date format was the trouble maker. Thanks for the tip. I have changed the date format to 'date +%d-%m-%Y' and $USER-$DATE.jpeg works beautifully.
The attendance register that I am making will give a welcome message on the console and ask for the name. When the employee punches in his/her name, the common script will calculate how late/early the person is with the reference time. It will also click a photo of the person and make a tiny image saved with that user's name and the current date. The time difference will be recorded in the csv file created with the same user's name. At the beginning of the month or end, a separate cron script will move all the user.csv files to another location. This ensures each csv file has a monthly data only. The original script will re-create the new csv files and append them daily.
On Wed, Mar 23, 2011 at 10:05 PM, Rony Bill gnulinuxist@gmail.com wrote:
The attendance register that I am making will give a welcome message on the console and ask for the name. When the employee punches in his/her name, the common script will calculate how late/early the person is with the reference time. It will also click a photo of the person and make a tiny image saved with that user's name and the current date. The time difference will be recorded in the csv file created with the same user's name. At the beginning of the month or end, a separate cron script will move all the user.csv files to another location. This ensures each csv file has a monthly data only. The original script will re-create the new csv files and append them daily.
An after thought. I don't need to move user.csv scripts anywhere. I just add a $month to the user.csv files and each one will be monthly automatically.
-- As a proper list etiquette..... Please trim your replies. Avoid cross posting to other lists. Members do not want to waste time answering same queries that may have been answered on other lists. Replies from other lists, to cross posted mails are not available to our members. Post your replies below the relevant original text, leaving a line space. Do not re-use old messages to write new ones. For new messages, create a new message.Regards,
Rony.
On Wednesday 23 March 2011 22:14:41 Rony Bill wrote:
On Wed, Mar 23, 2011 at 10:05 PM, Rony Bill gnulinuxist@gmail.com
wrote:
The attendance register that I am making will give a welcome message on the console and ask for the name. When the employee punches in his/her name, the common script will calculate how late/early the person is with the reference time.
You might want to add ntpdate to maintain proper time.
2011/3/24 jtd jtd@mtnl.net.in:
You might want to add ntpdate to maintain proper time.
ntpd, you mean. ntpdate cannot substitute for a properly configured ntpd. It is only a one-off time adjuster (usually a precursor to ntpd's startup).
Binand
On Wed, Mar 23, 2011 at 6:09 PM, Rony Bill gnulinuxist@gmail.com wrote:
Hello,
I am creating / appending files using a variable as the input name. Eg. $USER.jpeg makes a file called rony.jpeg . I want to add 2 variables to the file name instead of one and make $USER-$DATE.jpeg (rony-23/03/11.jpeg). What is the correct syntax for it as I keep getting errors in the mv as well as rename command. Tried $USER_$DATE or $USER.$DATE etc but no result. Did look up google but it has complex sed scripts.
$ echo $USER-$TERM mehul-xterm $ DATE=`date +%D` echo $USER-$DATE mehul-03/23/11 mehul@ubuntu:~$ touch $USER-$DATE touch: cannot touch `mehul-03/23/11': No such file or directory mehul@ubuntu:~$ mkdir $USER-$DATE mkdir: cannot create directory `mehul-03/23/11': No such file or directory
Maybe the above will help you after you've read Binand's reply.