LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   "ow to create and execute script" (https://www.linuxquestions.org/questions/linux-software-2/ow-to-create-and-execute-script-241258/)

zameer_india 10-11-2004 05:29 AM

"ow to create and execute script"
 
This is Zameer Ahmed Syed... I would like write a script to create a new user .... i am a new one to unix and Linux... OSs .... if some body have script to create user then After Creating a script how to execute the script file ..... please send me in mail i would really appreciate if some body helps me regding this issue....

Optionally one morething i would like to know

"what are the other interactive capabilities included in 'C' when compare with 'Bourne Shell'"


Thanq very much....
Zameer Ahmed Syed,
Hyd-India.

bulliver 10-11-2004 06:00 AM

Quote:

I would like write a script to create a new user
No need to...you most likely already have a script to do this called "useradd". For details on usage run "man useradd"

Quote:

what are the other interactive capabilities included in 'C' when compare with 'Bourne Shell
I'm not too sure what you mean by this, but C and shell scripting are two different beasts. For one, C is a compiled language which requires a specific "write code, compile, and test" cycle, and typically is not spoken of as "interactive" (of course you can write a C program which is interactive with the user...), while shell scripting, whether sh, bash, csh, zsh et al, are interpreted languages meaning you just "write and run" and see the results immediately.

ksraju007 10-11-2004 09:29 AM

Its very simple as described above also...

Create a file with lines of following format...

username:password:uid:gid:comments:homedir:shell

and issue the command...

#newusers filename

That's it. I have tested it here. If you are still getting errors,post contents of the file you created and the terminal output.

Enjoy!

__________________
Have a nice time....

Rajesh.

zameer_india 10-11-2004 11:10 PM

Good Morning Rajesh,

Thanq for nice reply....

This is the file which i created .... in vi editor.....
#!/usr/bin/newusers
aaa111:x:510:510:'just for example':/home/aaa111/bin/newusers
bbb111:y:512:512:'just for example':/home/bbb111/bin/newusers

and after that i saved it and run the following command ....

[root@redhat root]# newusers bulkusers

then it gives me error message like
newusers: line 1: invalid line
newusers: line 2: invalid line
newusers: line 3: invalid line
[root@redhat root]#

then i create new file .....
this time instead of newusers i use bash shell as follows...

#!/usr/bin/bash
aaa111:x:510:510:'just for example':/home/aaa111/bin/bash
bbb111:y:512:512:'just for example':/home/bbb111/bin/bash

then I saved it a file named "createallusers".. after that i run that file using bash shell like as

[root@redhat root]# bash createallusers

then it gives me following error message....

createallusers: line 2: aaa111:x:510:510:just for example: /home/ aaa111/ bin/
bash: No such file or directory
createallusers: line 3: bbb111:y:512:512:just for example: /home/ bbb111 /bin/
bash: No such file or directory

[root@redhat root]#

what was the error .... i think it is PATH Error .... I don't know how to set to PATH..

If u know how to set to PATH plz tell me the procedure.....

1. To whom we have to set the PATH ......it is for user or some other bash file
2. Could you know How to link Different shells ... if so plz tell me the procedure.

Thanq ....
with regds,
Zameer Ahmed Syed.

zameer_india 10-11-2004 11:25 PM

Good Morning Rajesh,

Thanq for nice reply....

This is the file which i created .... in vi editor.....
#!/usr/bin/newusers
aaa111:x:510:510:'just for example':/home/aaa111/bin/newusers
bbb111:y:512:512:'just for example':/home/bbb111/bin/newusers

and after that i saved it and run the following command ....

[root@redhat root]# newusers bulkusers

then it gives me error message like
newusers: line 1: invalid line
newusers: line 2: invalid line
newusers: line 3: invalid line
[root@redhat root]#

then i create new file .....
this time instead of newusers i use bash shell as follows...

#!/usr/bin/bash
aaa111:x:510:510:'just for example':/home/aaa111/bin/bash
bbb111:y:512:512:'just for example':/home/bbb111/bin/bash

then I saved it a file named "createallusers".. after that i run that file using bash shell like as

[root@redhat root]# bash createallusers

then it gives me following error message....

createallusers: line 2: aaa111:x:510:510:just for example: /home/ aaa111/ bin/
bash: No such file or directory
createallusers: line 3: bbb111:y:512:512:just for example: /home/ bbb111 /bin/
bash: No such file or directory

[root@redhat root]#

what was the error .... i think it is PATH Error .... I don't know how to set to PATH..

If u know how to set to PATH plz tell me the procedure.....

1. To whom we have to set the PATH ......it is for user or some other bash file
2. Could you know How to link Different shells ... if so plz tell me the procedure.

Thanq ....
with regds,
Zameer Ahmed Syed.


All times are GMT -5. The time now is 04:06 PM.