Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Accessing redirected file inside script Post 302105499 by sb008 on Friday 2nd of February 2007 06:13:19 AM
Old 02-02-2007
Quote:
Originally Posted by milhan
thanks a lot, but the file that is being redirected isn't recorded in my output file. The system I am using is SunOS 5.8. I tried it on Linux too, but linux didn't recognize the pfiles command at all. Here's my output when I run the 2 lines script on SunOS 5.8:
Code:
server:bash:/var/tmp > ./redirect.sh > out.dump
server:bash:/var/tmp > cat out.dump
4883:   /usr/bin/ksh ./redirect.sh
  Current rlimit: 256 file descriptors
   0: S_IFCHR mode:0600 dev:224,0 ino:132378 uid:4405 gid:7 rdev:24,4
      O_RDWR|O_LARGEFILE
   1: S_IFREG mode:0600 dev:224,5 ino:156220 uid:4405 gid:206 size:0
      O_WRONLY|O_LARGEFILE
   2: S_IFCHR mode:0600 dev:224,0 ino:132378 uid:4405 gid:7 rdev:24,4
      O_RDWR|O_LARGEFILE
  62: S_IFREG mode:0700 dev:224,5 ino:156219 uid:4405 gid:206 size:26
      O_RDONLY|O_LARGEFILE FD_CLOEXEC

server:bash:/var/tmp > cat ./redirect.sh
#!/usr/bin/ksh

pfiles $$

isn't there another way?

On Solaris 8 the output of pfiles is a bit limited. But still it can be done

You redirected stdout, so FD 1 (File Descriotor 1)

1: S_IFREG mode:0600 dev:224,5 ino:156220 uid:4405 gid:206 size:0
O_WRONLY|O_LARGEFILE

The line shows that FD 1 is related to inode number 156220 which happens to be the inode number for "out.dump"

If you know the exact location (directory) of the file you reirect to you can find out, based on the combination of the output of the commands "pfiles" and "ls -i <dir>", what the name is of the file where your output is directed to.

If you don't know the exact location but at least the the filesystem where to file is located, you can use:
find <root of filesystem> -inum <inode numver as reported by pfiles>

If you have no clue at all wherre the file is located you could use:
find / -inum <inode numver as reported by pfiles>

However in this last scenario more then 1 file could pop up, because on each filesystem there could be a file present with that inode number
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Saving a redirected file

What command do I use in order to save a file in directory A/B/C to directory A/D/E. (1 Reply)
Discussion started by: JSP
1 Replies

2. UNIX for Dummies Questions & Answers

accessing shell script variable in file

Hi, I have a shell script in which there is a file conn_$temp where $temp has the pid of the shell script. in this shell script i have an embedded awk script that must read the file while ((getline < "conn_$temp") > 0) However due to the "$temp" in the file name, the awk script is... (6 Replies)
Discussion started by: HIMANI
6 Replies

3. UNIX for Dummies Questions & Answers

redirected output not going to file for all cases

I have to confirm that an engine was not able to run. In the output below you see that it indeed got errors, but it didn't send those messages to the output file. When I run the same thing with a different executable it works. So does this mean something in the executable could cause it not to... (7 Replies)
Discussion started by: brdholman
7 Replies

4. UNIX for Dummies Questions & Answers

Accessing a log file from html, coldfusion script

I have a question. I am not even sure if it can be done. But if it could be then I would needs a lot of help. ok, I work for a software company and we have a store. The store log files are in a unix server and the log file is dynamically updated everytime some error occurs in the store. So we often... (1 Reply)
Discussion started by: skrules
1 Replies

5. Shell Programming and Scripting

Sed inside bash script - accessing multiple files

I have a file (email) containing email addresses. I have a second file (terms) that contains simple regular expressions and words/characters. Here are some examples: \.trainee \.group \.web I want to go through email and delete lines containing the expressions/words from terms and write... (1 Reply)
Discussion started by: manouche
1 Replies

6. UNIX for Dummies Questions & Answers

How to get redirected filename inside unix script

Hi All, I am having a script which calculate checks the input feed and perform some function. When i am executing this script i am redirecting this to a output file. I want to know the redirected output file name inside my scripts. Is there is any way to get that . like the same way we... (4 Replies)
Discussion started by: arunkumar_mca
4 Replies

7. Shell Programming and Scripting

Error during Accessing Global variable inside function

emailid=myemail@xyz.com taskName="DB-Backup" starttime=`date` email() { subject="$taskName" ": " $* " at `date` " mutt -s "$subject" $emailid < /dev/null } email "Starting" #do my stuff email "Finished" The above code gives following error ./dbbackup.sh: line 6: :... (5 Replies)
Discussion started by: nitiraj.rathore
5 Replies

8. Shell Programming and Scripting

Perl: accessing reference to variable inside hash.

Below is hash which contains reference to variables: my %mandatoryFields = ( 1 => \$msgtype, 2 => \$switchtype, 3 => \$card_nbr, 4 => \$natv_tran_type_code, 5 => \$amt_1 ); This... (0 Replies)
Discussion started by: som.nitk
0 Replies

9. Shell Programming and Scripting

Issue with accessing value inside while loop, outside it

Hi, GetName() { if then echo " Please enter the name: " read Name tempvar=0 while read line do if then tempvar=`expr $tempvar + 1` echo $tempvar ... (10 Replies)
Discussion started by: rituparna_gupta
10 Replies

10. Shell Programming and Scripting

Deleting redirected pwd from file.

Hi echo " username " read username echo "password" stty -echo read password stty echo through read i am taking standard input and redirecign them to a file echo " username=${username}/${password} " > file.lst now from the same shell script i want to delete the password (i.e... (4 Replies)
Discussion started by: rosheks
4 Replies
xfs_ncheck(8)						      System Manager's Manual						     xfs_ncheck(8)

NAME
xfs_ncheck - generate pathnames from i-numbers for XFS SYNOPSIS
xfs_ncheck [ -i ino ] ... [ -f ] [ -s ] [ -l logdev ] device DESCRIPTION
xfs_ncheck with no -i arguments generates an inode number and pathname list of all files on the given filesystem. Names of directory files are followed by /.. The output is not sorted in any particular order. The filesystem to be examined is specified by the device argument, which should be the disk or volume device for the filesystem. Filesystems stored in files can also be checked, using the -f flag. OPTIONS
-f Specifies that the filesystem image to be processed is stored in a regular file at device (see the mkfs.xfs -d file option). This might happen if an image copy of a filesystem has been made into an ordinary file. -l logdev Specifies the device where the filesystem's external log resides. Only for those filesystems which use an external log. See the mkfs.xfs -l option, and refer to xfs(5) for a detailed description of the XFS log. -s Limits the report to special files and files with setuserid mode. This option may be used to detect violations of security pol- icy. -i ino Limits the report to only those files whose inode numbers follow. May be given multiple times to select multiple inode numbers. If the filesystem is seriously corrupted, or very busy and looks like it is corrupt, a message of the form that would be generated by xfs_check(8) may appear. xfs_ncheck is only useful with XFS filesystems. SEE ALSO
mkfs.xfs(8), xfs_check(8), xfs(5). xfs_ncheck(8)
All times are GMT -4. The time now is 11:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy