Doubt on Executing unix commands in script

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Doubt on Executing unix commands in script
# 1  
Old 06-05-2006
Question Doubt on Executing unix commands in script

How can I execute the unix command "cd - Change directory" command, so that my command prompt should be reflected for that change.

Example : Now you are in your home directory i.e /home/naresh and you have some sub directory called unixinfo in your home directory. i want to write a script,so that if i execute that script my commnad prompt should go to that subdirectory.

I called cd /home/naresh/unixinfo command in script. But my command prompt is not changed. Can somebody please help me

I can use the alias command for this. But i am doing some mini project for that
i will pass argument(dir name) to my script will take the complete path from one
text i maintain and trying to change the directory to that path.
Can somebody suggest any alternative

Last edited by Naresh Kumar; 06-05-2006 at 12:06 PM..
# 2  
Old 06-05-2006

why do you need that. You can set up aliases if you had to type long directory listings.
alias name='cd /some/long/dir/name/to/where/you/want'

in your .profile file and use it.
# 3  
Old 06-05-2006
If you want to see which directory you cd'd to in your command prompt, add the following to your .profile (or in /etc/profile for everyone) :

PS1='$PWD" # "'

So if you are in your home directory, you'll see:

/home/naresh #

and you cd to unixinfo, your prompt will change to:

/home/naresh/unixinfo #

Note: this command form works in ksh (my shell of preference for over a decade) . If you are using another shell, the syntax may be different or not work.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

scp Commands not executing via cgi script

Hi, I have a CGI script, which includes a python custom header file. The cgi script calls a few functions. Py file. #resourcemanager creation def make_rm(rmip,nip,nport): fp = open("temp1.txt",mode="w") fp.write('<?xml version="1.0"?>\n<!-- Licensed under the Apache... (2 Replies)
Discussion started by: adi.6194
2 Replies

2. Shell Programming and Scripting

Commands not executing after FTP in shell script

Hello In the shell script we have a FTP command like below ftp -n -v -q >/infa/datafiles/GRP/Scripts/ftp_from_infa_dvcn.log<<END_SCRIPT   quote USER $FTP_USER quote PASS $FTP_PASS ascii lcd $FTP_LOCALDIR cd $FTP_FLDR put $FTP_FILE   bye exit If i... (1 Reply)
Discussion started by: Pratik4891
1 Replies

3. Shell Programming and Scripting

Doubt in getopts commands

I am new to getopts command. I wonder the if there is any built in way to detect that if both options occurred from where only on them is expected. command Correct command -a command -b Incorrect command -a -b command -ab Please clarify my doubt. (5 Replies)
Discussion started by: tamil.pamaran
5 Replies

4. Shell Programming and Scripting

Executing mutliple commands in Unix

Hi I always do a ftp in Unix to bring in a file from Mainframes. Then run a set of commands say 8 commands one by one to execute the brought in file. Upon completion of this commands, the data from the file gets transfered to Mainframe database. The problem is i can execute only 1 file at a time.... (2 Replies)
Discussion started by: cnelatur
2 Replies

5. Shell Programming and Scripting

Executing a shell script containing awk commands

Hi All, I am trying to execute a shell script containg awk commands. But unable to do so. Below is my script. Please help. The name of the script is and I have tried executing it using the command sh It is giving an error which reads like: awk:syntax error near line 7... (3 Replies)
Discussion started by: misb
3 Replies

6. UNIX for Advanced & Expert Users

Executing a shell script from windows;script present in unix

I need to execute a shell script kept in unix machine from windows. User id, password area available. For eg. There's a shell script wich moves all the logs kept in my home directory to a directory named LOGS. Now i need to get this done through windows; either using a batch file, or java... (4 Replies)
Discussion started by: rajneesh_kapoor
4 Replies

7. UNIX for Dummies Questions & Answers

Sending a mail from unix script doubt

HI i usually send an a file attachment in a mail from unix like following. mailx -s 'Job Success' < attachment.log But I have observed in several threads that we can also use uuencode and uudecode. What are they? when should we use uudecode and uuencode ... (1 Reply)
Discussion started by: rajesh_tns
1 Replies

8. Shell Programming and Scripting

Executing TL1 commands through script

HI , I have to write a script for some testing , which will telnet to a device and execute some TL1 commands.. Does any one knows how to execute TL1 commands through a script Thanks in advance Binu (1 Reply)
Discussion started by: msbinu
1 Replies

9. UNIX for Advanced & Expert Users

executing applications/commands on a unix server from a windows PC

i have a network drive (samba) mounted on to my PC and also i have SSH client on my machine. however i need to run applications/commands on a unix server from the middle of a different executable(windows compatable one). so i need to connect to the unix server from SSH through the... (1 Reply)
Discussion started by: megastar
1 Replies

10. UNIX for Dummies Questions & Answers

Unix + oracle doubt....involving shell script

....does the dbms_output.put_line work inside unix shell script? i mean this is to be inside the sqlplus connection as follows!! sqlplus -s $UP <<EOJ .. .. .. dbms_output.put_line ('Insertion procedure failed for UPC BC : ' || wk_key_value || ' Sqlcode: ' || SQLCODE || ' Error... (2 Replies)
Discussion started by: mexx_freedom
2 Replies
Login or Register to Ask a Question

Featured Tech Videos