酷!學園

技術討論區 => Linux 討論版 => 主題作者是: ahlek 於 2002-12-07 19:53

主題: shell script question
作者: ahlek2002-12-07 19:53
i want do a shell script connect to mysql to get some information on the user. and write it to the user /home/xxx/.test

e.g
in mysql got keep track all the users information like home address,telphone number,
so how do i writing a script connect to mysql get this kind of information and write to a file in each user /home/xxx/.test so then when each user login that time it can show the detail .test in their motd.
主題: shell script question
作者: netman2002-12-07 22:25
sorry i am not good at mysql at all.

so, could you tell me how you do the jobs in command lines?
once you can achieve datas manually, then you can got them in a script.
主題: shell script question
作者: ahlek2002-12-11 18:15
ok..how about if i got save all the user file in user.txt

then is it possible i can using shells script to read user.txt file
and create a simply test.txt in each user direcotry /home/xxx ???

the user.txt <--have all the user information .

e.g
user.tx
---------
login:ahlek
tel:003
address:testing

login:test
tel:004
address:test2

so i using shell script to create a file in /home/ahlek/test.txt
and this test.txt only got ahlek user detail
/home/ahlek/test.txt
--------
tel:003
address:testing

/home/test/test.txt
tel:004
address:test2

is it possible ??
主題: shell script question
作者: netman2002-12-11 23:39
grep -A2 "login:$USER" user.tx  | tail +2 > $HOME/test.txt
主題: shell script question
作者: ahlek2002-12-12 09:32
引述: "netman"
grep -A2 "login:$USER" user.tx  | tail +2 > $HOME/test.txt


To:netman
i have try grep -A2 "login:$USER" user.tx  | tail +2 >$HOME/test.txt
it wont work.. but if
grep -A2 "login:$USER" user.tx  | >/$home/test.txt
then it work..

but i have another question.
let say i wan using root to running while loop. auto
writing in each user folder . how can i do ?
sorry.i dont know much shell script one.
it means the $user <--i wan set variable how can i do ??

tks again
主題: shell script question
作者: netman2002-12-12 11:30
$USER is different to $user,
same for $HOME and $home....

also, /$HOME is different to $HOME too.