LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-05-2003, 09:30 PM   #1
slappydappy
LQ Newbie
 
Registered: Oct 2003
Posts: 3

Rep: Reputation: 0
Shell Script assignment...need MAJOR help!


I have been given an assignment for school, and well, I have no idea how to do it. Linux was not a pre-requisite for this class, and our book does not cover this or Linux at all. Our teacher still thinks we should somehow know how to do this. I have to write this in a UNIX prompt thing I telnet into, it says Red Hat Release 7.2 (Enigma) at the top. Below that it says Kernel 2.4.9-34smp on an i686.

I have looked all over the net at shell script tutorials but none have helped me progress to any point. I am not asking anyone to do my homework for me, I just need someone to point me in the right direction. I do not know anyone with linux or anyone who even uses it. I do not know what to do and I have nothing to turn to for help.

This is what is expected of me by tomorrow night:

-----------------------------------------------------------------------------------------------
2. Create a Linux batch file that at login time would set up your session’s environment so that the following “new” commands could be used for the standard Linux operating systems commands. Test the file to make sure that it works. Append this batch file to the above-mentioned Word file.



A. System prompt is changed to YOURLASTNAME (10 points)

B. Ultrix commands are replaced by the following (=> means replaced by): (30 points)

1) file copy => fcp

2) file rename => frn

3) file delete => fdl

4) create directory => cdr

5) change directory => dchg

6) display contents of a directory => dcd

7) delete directory => ddel

8) display date and time => ddt

9) go to mail => gml

10) logoff => out
 
Old 10-05-2003, 09:52 PM   #2
DavidPhillips
LQ Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163

Rep: Reputation: 58
This does not actually mean to replace the commands but to set an alias to the commands.

Search for info on using the alias command and where to put it to set the aliases for a user at login.


For the prompt look for info on setting the PS1 variable.

Last edited by DavidPhillips; 10-05-2003 at 09:54 PM.
 
Old 10-05-2003, 09:53 PM   #3
micxz
Senior Member
 
Registered: Sep 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
Well that's all easy stuff.
I'm not sure what your teacher means by a linux "batch file" sounds like a windows thing to me. You can accomplish the above with a shell script that exports different env $vars. Another way you could use your .profile or .bashrc.
But if your teacher wants you to turn in a script then, you should write one in bash.

Hints:
- PS1
- alias

Still need help?
 
Old 10-05-2003, 11:34 PM   #4
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Moved: Seems suitable in the Programming forum. Regards.
 
Old 10-06-2003, 02:39 AM   #5
slappydappy
LQ Newbie
 
Registered: Oct 2003
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks for helping, I made the file using VI and named the file batch. I run the file using ./batch and then it runs and then I get another prompt. But nothing changes, and the aliases dont work. Im confused to say the least. It doesnt give me any errors when I run the file.
 
Old 10-06-2003, 02:48 AM   #6
micxz
Senior Member
 
Registered: Sep 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
Well you didn't get any errors and you promt changed. Looks like your on your way!

Why don't you try some of the alias you created? Do they work? e.g. After running it and you execute, "ddt" do you get the date and time or do you get, "bash: ddt: command not found"?

What part don't you understand?
 
Old 10-06-2003, 04:27 AM   #7
jimveta
Member
 
Registered: Oct 2003
Location: los angeles
Posts: 32

Rep: Reputation: 15
looks like you're almost there.

it doesn't change or anything because when you execute a
program like " ./batch" that is lauching a completely seperate
program (another shell actually, kinda like temporarily telnetting
to the same host) so the things insisde of "batch" only works for
that seperate program
(.. and you get another prompt because that program "batch"
exited)

to make it effective in your current shell (what you get when
you telnet), just do: ". ./batch"

NOTE the beginning "." (dot)
i.e. <dot> <space> <dot><slash>batch

this makes it so that all the things inside batch act like you're
typing it into the command line (your current shell)
now you should see the change immediately after that.

try using the fcp aliased command you created on any file.
e.g. "fcp <pick a file> mynewfile"

because those commands inside of batch affect the current shell
once you do ". ./batch" (btw, the process is called "sourcing" a
file), if anythign goes really bad like certain usual commands
don't work, just exit your telnet session and log back in again.
 
Old 10-06-2003, 02:35 PM   #8
slappydappy
LQ Newbie
 
Registered: Oct 2003
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks everyone, I appreciate this so much. I got everything working and I can now turn the assignment in! Thank you!!!!
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script inside shell script treotan Linux - General 4 02-19-2009 06:34 AM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
[SHELL SCRIPT] Write at the right of the shell window Creak Linux - General 2 04-02-2004 03:00 PM
MAJOR problem ... bash script array HELP !!!!! michael_util Slackware 1 02-13-2004 06:51 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:59 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