calling current working dir from script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting calling current working dir from script
# 1  
Old 07-31-2006
calling current working dir from script

Hello,
I am having problem in setting current working directory from shell.
I want to set pwd as an environmental variable in a script. I am following an existing script which is defined as
HOME=$(shell dirname `pwd`)
C_HOME=$(shell echo $(HOME) | sed -e 's:\/:\\\/:g' )

But when I am trying to execute them, i am getting error:
shell: command not found

Please help.
# 2  
Old 07-31-2006
It looks to me like you are leterally following an example out of a book of from a web page that wasn't ment to be copied verbatim.

HOME=$(pwd) would be more correct
# 3  
Old 07-31-2006
Is it possible to use the terminology of .. $(shell ....
The reason I am asking you is...I want to implement these two below and I am not able to do so:

C_HOME=$(shell echo $(HOME) | sed -e 's:\/:\\\/:g' )
BH_HOME=$(shell rpm --showrc | grep macrofiles | sed -e 's/:/:$(C_HOME)/g' | sed -e 's/^\/usr/$(C_HOME)\/usr/' )

Smilie
# 4  
Old 07-31-2006
I think you are confused. You need not run it as:
Code:
$(shell...

It is just
Code:
$(<what ever command...>)

Make sure that you are using bash or ksh.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Save all the file of current date in another dir?

Hi i want to copy all the files of current date in another directory. for example, below i want to save all the file of 26 march to copied in debug dir. $ ls -lrt | tail -5 -rwxrwxrwx 1 khare guest 73 Jan 6 12:35 chk -rw-r--r-- 1 khare guest 770 Mar 26 02:21 cc1... (2 Replies)
Discussion started by: scriptor
2 Replies

2. Shell Programming and Scripting

how to copy current date files to another dir

i have directory /abcd and i want to copy all today date files in /xyz directory. i am able to see the files by using below command but not able to understand copy. find . -mtime -1 -type f -exec ls -l {} \; (2 Replies)
Discussion started by: learnbash
2 Replies

3. HP-UX

Unable to Set Prompt to current working DIR

HPUX does not recognise \h,\w,\u to display the hostname,working directory and username respectively. So how do i set the PS1 variable to display my current working Directory as my prompt? I also tried PS1=$PWD, But it keeps showing the same directory path as prompt which PWD was holding at... (3 Replies)
Discussion started by: Amit Kulkarni
3 Replies

4. Shell Programming and Scripting

Script calling another script not working

Hi, I'm new to this forum. I'm working on a Hyperion Essbase project and I'm responsible for the automation part of the piece. I am trying to execute 4 maxl script at the same time but it seem to be not working. Below is my script: #!/bin/sh # Maxl script to run export... (2 Replies)
Discussion started by: tmiller
2 Replies

5. Shell Programming and Scripting

ssh is not working while calling through expect shell script

Hi, Please share you experience and way out on below error:--> #!/bin/bash -xv FILE=login.txt + FILE=login.txt CONNECT=sshlogin.exp + CONNECT=sshlogin.exp SERVERNAME=$1 + SERVERNAME=192.168.12.1 MyServer="" + MyServer= MyUser="" + MyUser= MyPassword="" + MyPassword= exec 3<&0 +... (6 Replies)
Discussion started by: manish_1678
6 Replies

6. UNIX and Linux Applications

CPIO Problem, copy to the root dir / instead of current dir

HI all, I got a CPIO archive that contains a unix filesystem that I try to extract, but it extract to the root dir / unstead of current dir, and happily it detects my file are newer otherwise it would have overwrited my system's file! I tried all these commands cpio -i --make-directories <... (2 Replies)
Discussion started by: nekkro-kvlt
2 Replies

7. Shell Programming and Scripting

to write a script to compare the file size in the current directory and previous dir

hi, i am new to this site. i want to write a script to compare the file size of the files in the current dir with the files in the previous directory. the files name will be same, but the filename format will be as xyzddddyymm.txt. the files will arrive with the month end date(i want to... (5 Replies)
Discussion started by: tweety
5 Replies

8. Shell Programming and Scripting

a script to clone a dir tree, & overwrite the dir struct elsewhere?

hi all, i'm looking for a bash or tcsh script that will clone an empty dir tree 'over' another tree ... specifically, i'd like to: (1) specify a src directory (2) list the directory tree/hiearchy beneath that src dir, w/o files -- just the dirs (3) clone that same, empty dir hierarchy to... (2 Replies)
Discussion started by: OpenMacNews
2 Replies

9. UNIX for Dummies Questions & Answers

using grep to find a value in current dir and sub dirs?

Hey guys, I would like to find all files which contain "client1.dat". I would like to search from the current directory and all subs and print out all the files that have this. Any help would be greatly appreciated. Thanks much. (10 Replies)
Discussion started by: ecupirate1998
10 Replies

10. UNIX for Dummies Questions & Answers

Finding current working dir path

Hi Folks, In a Unix (ksh) script, is there a way to determine the current working directory path of another logged-in user? Of course, I can use "pwd" to find my own path. But, how do I find it for another active user? Thanks for any input you can provide. LY (6 Replies)
Discussion started by: liteyear18
6 Replies
Login or Register to Ask a Question