Redirecting script output to terminal | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Redirecting script output to terminal

Shell Programming and Scripting


Tags
redirection, script

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 12-05-2012
Raviteja saddal Raviteja saddal is offline
Registered User
 
Join Date: Dec 2012
Last Activity: 5 December 2012, 9:02 AM EST
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Redirecting script output to terminal

When ever i started my terminal,Every time I have to change the directory like "
Code:
cd user/documents/ravi/folder2/folder3

" Without typing this entire command every time ,I placed "
Code:
alias c='cd user/documents/ravi/folder2/folder3'

" in .bash_profile file. so that i can able to execute command 'c' from any directory without any issues . But my requirement is --> the command "
Code:
cd user/documents/ravi/folder2/folder3

" should be in a shellscript . I want to execute that script to change the directory from anywhere . For that i have created one script (change.sh) having content [ICODE]echo "change script "
cd user/documents/ravi/folder2/folder3[/CODE]" in user/documents directory . In .bash_profile file i put "
Code:
export PATH=$PATH:user/documents

" . No i can able to execute the script from any where . I am getting output as change script . when i am trying to print present working directory PWD ,It is not getting to change the directory . the problem is --the output of changing the directory from script is not getting redirected to terminal . Can any one help me to come out of this ......

Last edited by Scrutinizer; 12-05-2012 at 10:39 AM.. Reason: Added code tags
Sponsored Links
    #2  
Old 12-05-2012
michaelrozar17's Avatar
michaelrozar17 michaelrozar17 is offline
Registered User
 
Join Date: Jul 2010
Last Activity: 24 November 2014, 9:59 PM EST
Location: IN
Posts: 892
Thanks: 14
Thanked 182 Times in 173 Posts
Understood but not completely. So you telling when you do echo $PWD in terminal your not getting the required output?
Sponsored Links
    #3  
Old 12-05-2012
Raviteja saddal Raviteja saddal is offline
Registered User
 
Join Date: Dec 2012
Last Activity: 5 December 2012, 9:02 AM EST
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
YES .
After executing that script file , i tried pwd to get the present working directory . my requirement is that directory has to changed to "user/documents/ravi/folder2/folder3" but it is not changed .
    #4  
Old 12-05-2012
Vikram_Tanwar12 Vikram_Tanwar12 is offline
Registered User
 
Join Date: Nov 2012
Last Activity: 21 November 2013, 3:32 AM EST
Posts: 168
Thanks: 13
Thanked 10 Times in 10 Posts
What is the output you are getting after pwd command ?
Sponsored Links
    #5  
Old 12-05-2012
Raviteja saddal Raviteja saddal is offline
Registered User
 
Join Date: Dec 2012
Last Activity: 5 December 2012, 9:02 AM EST
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
For example now i am in a directory "user/documents".I have executed the script for changing the directory to "user/documents/ravi/folder2/folder3" . After that I have tried pwd and i got output as "user/documents" . but i need output as "user/documents/ravi/folder2/folder3"
Sponsored Links
    #6  
Old 12-05-2012
phunk phunk is offline
Registered User
 
Join Date: Nov 2012
Last Activity: 28 February 2014, 3:57 PM EST
Posts: 35
Thanks: 3
Thanked 1 Time in 1 Post
Holy mother of God that first post was a pain to read...

Can you [ code ] your shell script for me?

I'm not entirely sure what you're issue is. Try /user/documents/ravi/folder2/folder3 .
Sponsored Links
    #7  
Old 12-05-2012
Vikram_Tanwar12 Vikram_Tanwar12 is offline
Registered User
 
Join Date: Nov 2012
Last Activity: 21 November 2013, 3:32 AM EST
Posts: 168
Thanks: 13
Thanked 10 Times in 10 Posts
I agree with Phunk .You should use the full path from the root that means / .


Code:
/user/documents/ravi/folder2/folder3

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
redirecting script output GmGeubt UNIX for Dummies Questions & Answers 4 10-02-2011 07:20 PM
redirecting the script output to more than 1 file boopathyvasagam UNIX for Dummies Questions & Answers 2 01-24-2011 08:53 AM
redirecting SQL output from within a shell script soliberus Shell Programming and Scripting 2 11-23-2007 08:29 AM
Redirecting to standard output from within called script vigneshra Shell Programming and Scripting 8 07-04-2006 11:19 PM
redirecting one terminal into an other?? piltrafa UNIX for Dummies Questions & Answers 4 06-01-2002 03:07 AM



All times are GMT -4. The time now is 09:24 PM.