LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-30-2003, 04:23 PM   #1
rocketgo
Member
 
Registered: Oct 2003
Posts: 37

Rep: Reputation: 15
shell scripts


Ok here it goes me and my teacher of my linux class at school both have different options on this i say it can be done but he said that it cant but i cant prove him wrong so i hope you guys can help.


what we need to do is write a shell script that creates a user and adds the $HOME variable to the PATH Statement for that user

I know how to do it with out a shell script but i dont know how to make a shell script do it any help would be welcome

Last edited by rocketgo; 11-30-2003 at 04:24 PM.
 
Old 11-30-2003, 05:26 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Do it manually.

Load ~/.bash_history into your favourite editor.

Remove all lines that didn't have to do with your
process ...

insert
#!/bin/bash
at the top

replace the bits where you typed the username
with a $1

save it as:
create.sh

chmod +x create.sh


:}



Cheers,
Tink
 
Old 11-30-2003, 05:31 PM   #3
rocketgo
Member
 
Registered: Oct 2003
Posts: 37

Original Poster
Rep: Reputation: 15
dont understand

sorry but i dont understand what you mean is there any other way to expain it


Thanks
 
Old 11-30-2003, 05:42 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
You said you knew how to do it manually.

And I suggested to do that, and then turn
what you did into a bash-script afterwards.
Which bit did you not understand?


Cheers,
Tink
 
Old 11-30-2003, 08:36 PM   #5
rocketgo
Member
 
Registered: Oct 2003
Posts: 37

Original Poster
Rep: Reputation: 15
edit

i dont know how to edit a file useing a shell script
 
Old 11-30-2003, 08:44 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
i dont know how to edit a file useing a shell script
Which file are you trying to edit, what
are you doing from the command line
to do so?

You can use sed/awk to edit streams
(e.g. piping the file through them).


Cheers,
Tink
 
Old 11-30-2003, 09:00 PM   #7
flava
LQ Newbie
 
Registered: Jun 2003
Location: Los Angeles, CA
Distribution: Kubuntu
Posts: 8

Rep: Reputation: 0
rocket go looks like a newb that hasn't discovered pico/nano.

keep going to class and don't have meaningful discussions with your "linux teacher"

Tinkster rulz
 
Old 11-30-2003, 09:36 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally posted by flava
rocket go looks like a newb that hasn't discovered pico/nano.

keep going to class and don't have meaningful discussions with your "linux teacher"

Tinkster rulz
Thanks, but I don't :}

I think what he meant is that from the shell
he would edit /etc/passwd and ~/.profile
using vi or something to that effect, and
he doesn't know how to do e.g. vi from
a script (which is fair enoough ;}) ...


Cheers,
Tink
 
Old 11-30-2003, 10:01 PM   #9
rocketgo
Member
 
Registered: Oct 2003
Posts: 37

Original Poster
Rep: Reputation: 15
yes thank you Tinkster i know there is a way to use vi to edit a file in a shell script but i cant get it to work
 
Old 11-30-2003, 11:16 PM   #10
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Use awk or sed then.
Or tell me what you want to achieve?
Like in what the expected result would be?


Cheers,
Tink
 
Old 12-01-2003, 05:20 AM   #11
fatgod
Member
 
Registered: Mar 2002
Location: Edinburgh, Scotland
Distribution: Suse 7.2, Gentoo 1.4, Solaris 9
Posts: 661

Rep: Reputation: 30
rocketgo. Dude.

If you can do it manually then you can do it in a shell script... just post here what the manual steps are and Tinkster, myself or someone will show you what you need to change/do to make it work in a script... I'm always eager to prove the teaching establishment knows less than it should
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with shell scripts thorney Linux - Newbie 4 11-27-2005 11:18 PM
Shell Scripts benwy Linux - Software 1 06-09-2003 02:58 AM
Shell scripts anon227 Linux - Software 1 01-03-2003 03:11 PM
shell scripts nautilus_1987 Linux - General 3 08-30-2002 03:12 AM
shell scripts gui10 Programming 10 10-28-2001 02:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration