Hi !
I have searched in the forum, but i'm not able to combine various solution to help me !
My problem is very simple for a bash scripter or a old linux man, but not for me (novice and inexperienced).
I need to store in a mysql database the output of "last" command, but the table where i need to store the data have only few TEXT fields.
So, i must split the line in a few fixed fields, and store in my mysql db.
The output of "last" command
axel pts/0 :0.0 Wed Feb 3 21:39 still logged in
axel tty7 :0 Wed Feb 3 21:39 still logged in
mark pts/2 :0.0 Wed Feb 3 21:37 - 21:38 (00:01)
axel tty7 :0 Wed Feb 3 21:34 - 21:38 (00:04)
reboot system boot 2.6.31-18-generi Wed Feb 3 21:33 - 00:23 (02:49)
tucky pts/0 :0.0 Wed Feb 3 21:18 - 21:33 (00:14)
tucky tty7 :0 Wed Feb 3 21:16 - down (00:16)
reboot system boot 2.6.31-18-generi Wed Feb 3 21:15 - 21:33 (00:17)
so I decided to split this way:
For "still logged":
axel,pts/0,:0.0,Wed Feb 3 21:39,still logged in
For "normal":
mark,pts/2,:0.0,Wed Feb 3 21:37 - 21:38,(00:01)
For "reboot or shutdown":
reboot,system boot,2.6.31-18-generi,Wed Feb 3 21:15 - 21:33,(00:17)
In this way I need only 5 fields..
Someone can help me to make this bash shell script ?
Many thanks in advance..
Axel