Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

creating a batch file.

Posted on 2006-06-21
13
Medium Priority
?
571 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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

972 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