Solved

creating a batch file.

Posted on 2006-06-21
13
559 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
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
 

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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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 500 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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 demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

705 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now