Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 576
  • Last Modified:

creating a batch file.

How do I creat a linux batch file and / or script that at at login time would set up my sessions environment so that the following "new" commands could be used for the standard linux operting systems commands.
Upon login system prompt is changed to YOURLASTNAME>
Linux commands are expanded to include your customized commands
display contents ofa directory =>mycd
display date and time=>mydt
logoff=>myexit
 
0
joshuaamzat
Asked:
joshuaamzat
1 Solution
 
slyongCommented:
Hi,

> Upon login system prompt is changed to YOURLASTNAME>
in your .bash_profile:
LNAME=yourlastname
PS1='${yourlastname}>'

> display contents ofa directory =>mycd
in your .bash_profile:
alias mycd='ls $1'

> display date and time=>mydt
in your .bash_profile:
alias mydt='date'

The last one might be a bit tricky.. are you using XWindows? or just console?
> logoff=>myexit
in your .bash_profile:
alias myexit='exit'
0
 
joshuaamzatAuthor Commented:
I guess I have no clue about this program. So please help me out. What screen should I be on to eneable me see the login and type these information in?
How do I create the .bash_profile?
Do I include > like you have on here or not?
Thanks for your help in advance
0
 
slyongCommented:
Since you are asking in Linux Programing area, I am assuming that you are using Linux?  Do you know which distribution are you using?  Are you using X-Windows or just console?
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
joshuaamzatAuthor Commented:
I have not done this before. But I was asked to create a file using pico text editor. I did do that but then the second part is what i have a problem with. I usually go thru the following steps in my windows XP to get into the system I am using:
start
run
type cmd
at prompt type telnet gator.uhd.edu
after that I type in all the scripts and create my directories
then at the prompt I type pico
this then takes me to a blank screen

So I don't know if that is a hard way to do it.
I need a straight forward instruction that is something better than what I am doing now with this pico thing.
0
 
slyongCommented:
Is this a home assignment problem by any chance?
0
 
joshuaamzatAuthor Commented:
Nope
0
 
slyongCommented:
ok since you have only telnet access you can only use pico, or vi.  pico is much much simpler then vi, so stick with pico.  Do as usual telnet into gator.uhd.edu.  After that, could you do a ls -l ~/ and see if there is a .bash_profile or .bashrc or .profile in there?
0
 
joshuaamzatAuthor Commented:
No sir there is no .bash_profile or .bashrc or .profile in my list of directories.
0
 
joshuaamzatAuthor Commented:
how do I go about creating one?
0
 
slyongCommented:
you can use pico:

$ pico .profile

However, since I am not sure which Unix system you are using and which shell you are using, I am not sure if those things that I do will work.  You have to know what shell you are dealing with.
0
 
joshuaamzatAuthor Commented:
hi, thanks for the effort so far but how do i know what shell iam working with?
0
 
KurtVonCommented:
echo $SHELL

and use

uname -a

to get a list of the kernel type and version, which can also be useful.  And, for the record, .bashrc is only going to show up if you use the command

ls -al

Hope this helps.
0
 
ahoffmannCommented:
# anthing below without a leading # is a command to type in when you logged in via telnet

cd ~
pico .bachrc
# now you're in pico, add all following lines down to but excluding #EOpico, then save the file and exit pico
LNAME=`awk -F: '/^'$USER'/{print $5}' /etc/passwd | awk '{print $2}'`
PS1='${yourlastname}>'
alias mycd='ls -la'
alias mydt='date'
alias myexit='exit'
#EOpico

# logout and log in again, then your commands should be available
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now