04-11-2007
working directory.
In VC++ we can set the path in project =>swttings=>working directory.
What if we want 2 do same in UNIX.
i.e.
our source files are at diff location.
We have to copy executable to required diff location and run it.
9 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I need to CD to a particular directory to check log files and interface files. Instead of typing the path manually, is there a way of getting a script to change my working directory to the one I need?
Currently I have a script that CD's to the directories I need but a soon as the script exits,... (5 Replies)
Discussion started by: jagannatha
5 Replies
2. UNIX for Dummies Questions & Answers
Hello All, I am trying to list only directories in my current directory using the command "ls -d". But the output only contains the default directory "." and doesn't list the rest of the directories in the working directory. Can anyone explain why this is happening (2 Replies)
Discussion started by: igandu
2 Replies
3. Shell Programming and Scripting
Hi All
I was wondering what is the most efficient way to find files in the current directory(that may contain 100,000's files), that meets a certain specified file type and of a certain age.
I have experimented with the find command in unix but it also searches all sub directories. I have... (2 Replies)
Discussion started by: kewong007
2 Replies
4. Shell Programming and Scripting
Can someone tell me how do i set my current working directory in my prompt?
Note: I dont want to use env variable PWD and using `pwd` gives me only my home directoy. suggest a different way ?
I use /bin/sh
thanks!! (3 Replies)
Discussion started by: yesmani
3 Replies
5. Programming
(I have mentioned about this situation and arisen problems in another thread: Is there a limit for a code line length in C?, but those questions are OffTop for that subject; so I open a new topic, here.)
The main problem is that I have some situation in my program where memory has been changed... (2 Replies)
Discussion started by: alex_5161
2 Replies
6. UNIX for Dummies Questions & Answers
Hi,
I want that the prompt that is being displayed (i.e $ sign) should display always the current directory I am working in instead of that $ sign
example:
as we use PS1=patric and the prompt changes from $ to patric OR
if we write the command PS1=`pwd` it will display the current... (5 Replies)
Discussion started by: premjotsingh
5 Replies
7. Shell Programming and Scripting
Hi everyone,
I have an Linux FTP script to get files from different AS400 mailboxes and store in different local directories.
I had to use mget * option becuase there is no fixed destination file name means filename can change.
The following FTP script is working fine if we have single file... (5 Replies)
Discussion started by: oravikiran
5 Replies
8. UNIX for Dummies Questions & Answers
Hi all,
How do I print the name of my current working directory only to screen?
Not pwd!
For example, if I was in /home/work I am looking for 'work' only (4 Replies)
Discussion started by: jimjam
4 Replies
9. Solaris
I have a 64 bit program called drivertest that crashed with the error message
Illegal Instruction (core dumped)
I tried to open the core file using dbx command bit it gives the below error message.
psrux902b1% dbx - core.drivertest.28276
Corefile specified executable:... (1 Reply)
Discussion started by: old_as_a_fossil
1 Replies
Cwd(3pm) Perl Programmers Reference Guide Cwd(3pm)
NAME
Cwd - get pathname of current working directory
SYNOPSIS
use Cwd;
my $dir = getcwd;
use Cwd 'abs_path';
my $abs_path = abs_path($file);
DESCRIPTION
This module provides functions for determining the pathname of the current working directory. It is recommended that getcwd (or another
*cwd() function) be used in all code to ensure portability.
By default, it exports the functions cwd(), getcwd(), fastcwd(), and fastgetcwd() into the caller's namespace.
getcwd and friends
Each of these functions are called without arguments and return the absolute path of the current working directory.
getcwd
my $cwd = getcwd();
Returns the current working directory.
Re-implements the getcwd(3) (or getwd(3)) functions in Perl.
Taint-safe.
cwd
my $cwd = cwd();
The cwd() is the most natural form for the current architecture. For most systems it is identical to `pwd` (but without the trailing
line terminator).
Taint-safe.
fastcwd
my $cwd = fastcwd();
A more dangerous version of getcwd(), but potentially faster.
It might conceivably chdir() you out of a directory that it can't chdir() you back into. If fastcwd encounters a problem it will
return undef but will probably leave you in a different directory. For a measure of extra security, if everything appears to have
worked, the fastcwd() function will check that it leaves you in the same directory that it started in. If it has changed it will "die"
with the message "Unstable directory path, current directory changed unexpectedly". That should never happen.
fastgetcwd
my $cwd = fastgetcwd();
The fastgetcwd() function is provided as a synonym for cwd().
abs_path and friends
These functions are exported only on request. They each take a single argument and return the absolute pathname for it.
abs_path
my $abs_path = abs_path($file);
Uses the same algorithm as getcwd(). Symbolic links and relative-path components ("." and "..") are resolved to return the canonical
pathname, just like realpath(3).
Taint-safe.
realpath
my $abs_path = realpath($file);
A synonym for abs_path().
Taint-safe.
fast_abs_path
my $abs_path = fast_abs_path($file);
A more dangerous, but potentially faster version of abs_path.
This function is Not taint-safe : you can't use it in programs that work under taint mode.
$ENV{PWD}
If you ask to override your chdir() built-in function,
use Cwd qw(chdir);
then your PWD environment variable will be kept up to date. Note that it will only be kept up to date if all packages which use chdir
import it from Cwd.
NOTES
o Since the path seperators are different on some operating systems ('/' on Unix, ':' on MacPerl, etc...) we recommend you use the
File::Spec modules wherever portability is a concern.
o Actually, on Mac OS, the "getcwd()", "fastgetcwd()" and "fastcwd()" functions are all aliases for the "cwd()" function, which, on Mac
OS, calls `pwd`. Likewise, the "abs_path()" function is an alias for "fast_abs_path()".
SEE ALSO
File::chdir
perl v5.8.0 2002-06-01 Cwd(3pm)