?
Solved

creating a batch file.

Posted on 2006-06-21
13
Medium Priority
?
568 Views
Last Modified: 2010-04-21
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
Comment
Question by:joshuaamzat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
13 Comments
 
LVL 24

Expert Comment

by:slyong
ID: 16956830
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
 

Author Comment

by:joshuaamzat
ID: 16957097
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
 
LVL 24

Expert Comment

by:slyong
ID: 16957126
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
Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

 

Author Comment

by:joshuaamzat
ID: 16957168
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
 
LVL 24

Expert Comment

by:slyong
ID: 16957176
Is this a home assignment problem by any chance?
0
 

Author Comment

by:joshuaamzat
ID: 16957225
Nope
0
 
LVL 24

Expert Comment

by:slyong
ID: 16957240
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
 

Author Comment

by:joshuaamzat
ID: 16957300
No sir there is no .bash_profile or .bashrc or .profile in my list of directories.
0
 

Author Comment

by:joshuaamzat
ID: 16957372
how do I go about creating one?
0
 
LVL 24

Expert Comment

by:slyong
ID: 16957725
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
 

Author Comment

by:joshuaamzat
ID: 16959226
hi, thanks for the effort so far but how do i know what shell iam working with?
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 16960940
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
 
LVL 51

Accepted Solution

by:
ahoffmann earned 1500 total points
ID: 16967929
# 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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question