stdout to file or character device with trailing slash


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting stdout to file or character device with trailing slash
# 1  
Old 01-13-2011
stdout to file or character device with trailing slash

I have an interesting one for the gurus out there that may have an idea as to why this is happening. We're currently migrating from Solaris 9 to Solaris 10 and we've run into a very strange issue. There are a bunch of shell scripts people have written throughout a directory that are used for particular systems that have code in there that directs output to /dev/null/ (notice the trailing slash). I suspect this started from someone making the mistake and then copying it through other scripts. e.g.
Code:
echo "bla" > /dev/null/

I understand that this is wrong syntax however on Solaris 9, using all shells, it allows this to go through. Actually, I can put as many trailing slashes as I went (e.g. /dev/null////) and it will just ignore. On Solaris 10, however, it will error out with "Is not a directory". Also, on other Linux/UNIX distros it errors out with the same behavior.

I am probably just going to recursively replace these instances with proper formed code however I'm just wondering if someone has any thoughts on this.

Last edited by Franklin52; 01-14-2011 at 05:28 AM.. Reason: Code tags
# 2  
Old 01-13-2011
Perhaps you could correct all the scripts at once (test it out first):
Code:
perl -i -pe 's|/dev/null/|/dev/null|g' *.sh

Code:
perl -i -pe 's|(?<=/dev/null)/||g' *.sh

# 3  
Old 01-13-2011
This discusses what is allowed for pathanmes by POSIX:

General Concepts

Trailing slash resolution is implementation defined.
# 4  
Old 01-13-2011
@Jim

I read:
Quote:
A pathname that contains at least one non-slash character and that ends with one or more trailing slashes shall be resolved as if a single dot character ( '.' ) were appended to the pathname.
# 5  
Old 01-13-2011
I see...so previous versions of Solaris could implement pathname resolution in such a way that trailing slashes are ignored in this manner. I've just found out that our developers even have it specified in their strcopy functions in their C utilities. E.g. they have shell commands with a trailing slash when doing redirect, e.g.:
Code:
strcpy(tmp, "rm -f bla.tmp 2> /dev/null/");

I actually can't find any other Linux/Unix system available to me at the moment that allows this sort of behaviour except our Solaris 9 machines...

Very very frustrating and going to mean a lot of sophisticated search and replace commands and recompiling for the guys to have this working. The annoying thing is that I know the proper thing to do is push them back on this however if only there was some way of hacking around this initially.


Moderator's Comments:
Mod Comment Please use code tags when posting data and code samples!

Last edited by Franklin52; 01-14-2011 at 05:29 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Sed: couldn't write 1378 items to stdout: No space left on device

Hi , In file first line start with "",when trying to remove using sed i am getting the below error .Please advise sed -e 's///g' -e 's/$]//g' segment1.txt >>segment_m1 sed: couldn't write 1378 items to stdout: No space left on device Thanks, Mohan (1 Reply)
Discussion started by: mohan705
1 Replies

2. Shell Programming and Scripting

Double slash into a file

I need to add double slash into a file using "echo" command. I tried the below from the command line and it worked. echo "\\\\abcd\efgh" > file more file \\abcd\efgh but if i use the same command within a script its showing only 1 slash Pls help (2 Replies)
Discussion started by: gpk_newbie
2 Replies

3. Shell Programming and Scripting

awk trailing character removal

Hi, The command - id | awk '{print $1}' - returns the following: uid=9028(luke) What do I need to further that awk so that I only have "luke", I want to set this as a variable. Thanks in advance, Lukas. P.S: I've come up with: USER1=`id | awk F'(' '{print $2}' | awk -F')' '{print... (4 Replies)
Discussion started by: luke222010
4 Replies

4. UNIX for Advanced & Expert Users

How the user process can access the character device loaded by my module

I am trying to load into the kernel a system-call dynamically (without restarting the kernel and compailing it) in an attempt to (once in kernel mode) write to user process's memory. (I know there is a way to do this with the ptrace interface but it is not an option.) I know the only way to... (1 Reply)
Discussion started by: hopelessProgram
1 Replies

5. Shell Programming and Scripting

Awk: Searching for length of words between slash character

Dear UNIX Community, I have a set of file paths like the one below: \\folder name \ folder1 \ folder2 \ folder3 \ folder4 \\folder name \ very long folder name \ even longer name I would like to find the length of the characters (including space) between the \'s. However, I want... (6 Replies)
Discussion started by: vnayak
6 Replies

6. Linux

sed couldn't flush stdout no space left on device

I am running Oracle Linux enterprise server 5.0. I just installed JDE 9.0 and after I started Webserver my root directory is 100% full. Can some one help me flush stdout. I am new to linux. Sam (5 Replies)
Discussion started by: s1a2m3
5 Replies

7. Shell Programming and Scripting

Using sed to append backward slash before forward slash

Hi all, I need to know way of inserting backward slash before forward slash. My problem is that i need to supply directory path as an argument while invoking cshell script. This argument is further used in script (i.e. sed is used to insert this path in some file). So i need to place \ in front... (2 Replies)
Discussion started by: sarbjit
2 Replies

8. UNIX for Advanced & Expert Users

Substitute single backward-slash with the double backward-slash

Hi, I have a path like this c:\test\sample\programs, i need to change thiis to c:\\test\\sample\\programs. How to perform this? I tried tr command but it didn't help me. Thanks Vijayan (3 Replies)
Discussion started by: mvictorvijayan
3 Replies

9. Shell Programming and Scripting

trailing slash - resync command

Hi All, i am aware that there is a difference between: 1. rsync -n -av /tmp . 2. rsync -n -av /tmp/ . I would like to do the first option. But if i use a variable (rsync -av $log .), the command behaves like a second option (with the trailing slash) Is there any way to use a... (2 Replies)
Discussion started by: c00kie88
2 Replies

10. UNIX for Dummies Questions & Answers

Shell script: Cut / (slash) character in string

I have a string "\/scratch\/databases\". I want to have a new string "\/scratch\/databases" by cutting last '\' character using shell script. I can't do this Please help me. Thanks in advance ThuongTranVN (4 Replies)
Discussion started by: ThuongTranVN
4 Replies
Login or Register to Ask a Question