pwd & cd commands not working in shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting pwd & cd commands not working in shell script
# 1  
Old 07-04-2007
pwd & cd commands not working in shell script

Here is my script

#!/bin/bash
pwd
cd /var/lib/pgsql

Both "pwd" and "cd" are not executed is there any other way i can change the current working directory to /var/lib/pgsql pls help!
# 2  
Old 07-04-2007
Quote:
Originally Posted by perk_bud
Here is my script

#!/bin/bash
pwd
cd /var/lib/pgsql

Both "pwd" and "cd" are not executed is there any other way i can change the current working directory to /var/lib/pgsql pls help!
Do you want to change current working directory by running this script? Then run your script as follows
Code:
. script_name

Note the space between dot and script_name
# 3  
Old 07-04-2007
I want to display the result of the current working directory in the script how do i do it
# 4  
Old 07-04-2007
Quote:
Originally Posted by perk_bud
I want to display the result of the current working directory in the script how do i do it
Can you explain this? I dont get you.
# 5  
Old 07-04-2007
I want to use the follwing command

pwd in the script but it says command not found after executing
# 6  
Old 07-04-2007
Quote:
Originally Posted by perk_bud
I want to use the follwing command

pwd in the script but it says command not found after executing
Can you show the exact error message you are getting?
# 7  
Old 07-04-2007
Thanks for helping me actually i was making a very sily mistake as some garbage characters were getting into my script any way thanx a lot
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SFTP Shell Script Get & Delete && Upload & Delete

Hi All, Do you have any sample script, - auto get file from SFTP remote server and delete file in remove server after downloaded. - only download specify filename - auto upload file from local to SFTP remote server and delete local folder file after uploaded - only upload specify filename ... (3 Replies)
Discussion started by: weesiong
3 Replies

2. Shell Programming and Scripting

Sftp commands not working in shell script

hi, i am having 2 linux boxes as source and 1 linux box as destination.i want to create a shell script containing code to transfer a csv file from either of the 2 linux boxes (file will be present in just one box, i need to check both the boxes to see which box has the csv file) to 3rd linux box... (1 Reply)
Discussion started by: linuxlearn2013
1 Replies

3. UNIX for Advanced & Expert Users

script & issues with non-AIX commands

I need to capture lengthy screen puts and direct to .txt. Script command is started on Wed Aug 22 13:27:36 EDT 2012. # qcp sh: qcp: not found. An issue I have is that script command doesn't take non-AIX commands. I need to run application-specific commands and capture the output in... (2 Replies)
Discussion started by: Daniel Gate
2 Replies

4. Shell Programming and Scripting

script to change shell's pwd

Hi there, i was presented with a challenge that is beyond my current shell knowledge: how can you have a script that executed interactive will change your current working directory? Example (under MacOS): 1. start Terminal and my current working directory is my home folder 2. execute a... (3 Replies)
Discussion started by: gigagigosu
3 Replies

5. Shell Programming and Scripting

Commands not working in script file

Hi All, I have created a shell script having some general copying and moving commands. Commands are working fine in Shell but while executing the shell script it is showing an error mv: cannot stat `/apps/orarpt/in/*': No such file or directory command is mv $IN_DIR* $ARCHIVE_DIR where... (5 Replies)
Discussion started by: maindola.amit
5 Replies

6. Shell Programming and Scripting

Parameters passed to commands but not working in Bash shell

Hi, I am trying to do this thing useing my shell bash ( sorry for my english ) I have in a file 63 hostnames, i wanna ask to the DHCP admin, to reserv that reserves 63 IP addresses of this hosts, using their mac address. I have thinked this script: for ((i=1;i<63;i++)); do arp $(head... (10 Replies)
Discussion started by: Cypress
10 Replies

7. Shell Programming and Scripting

How to get shell commands working through ruby?

Hi all, I am a newbie currently trying to execute shell commands from ruby instead of a shell script.(This method is conceived only for solaris so no issues with porting to other OS and all) Eg: Consider the command 'ls" with a shell script ,I would use it like this bash# ls <all the... (4 Replies)
Discussion started by: wrapster
4 Replies

8. Shell Programming and Scripting

running script in cron - with ssh commands - not working

I ran an ssh command to run a script on a remote server ssh -l <user> <servername> /path/to/script/scriptname This works fine - and the script is executed correctly. However - I put this command into a script, that I want to run from cron every hour, to execute the file on the remote... (31 Replies)
Discussion started by: frustrated1
31 Replies

9. Forum Support Area for Unregistered Users & Account Problems

forgot pwd & email address has changed

OK. Now that I can see that this will not go public, my old email address is removed. The new email is removed. I don't know my user name or pwd for this forum but I have registered. The forgotten pwd utility recognized my old email address, so I know I'm registered. Any help with updating my info... (1 Reply)
Discussion started by: forgot
1 Replies

10. IP Networking

ftp dir and pwd commands

Hi, I have a conenction to remote server that I'm sending files too via FTP. The problem I have is that when the file gets delivered it is 0 (zero) size. I've manually connected and logged on. The only command I can successfully execute is pwd. When I do a dir or a put command it will... (7 Replies)
Discussion started by: nhatch
7 Replies
Login or Register to Ask a Question