Sponsored Content
Top Forums Shell Programming and Scripting Difficulty with CAT redirection in script Post 302990314 by Don Cragun on Tuesday 24th of January 2017 01:37:31 PM
Old 01-24-2017
I'm glad we worked it out. Sometimes the obvious possibility just seems to unlikely to ask about. Smilie
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

redirection to tty** with cat

I tried to cat a file to another user that was logged in, but I received an error message that displayed something like: %cat funny > /dev/ttyp3 zsh: permission denied: /dev/ttyp3 Thank you all for your help (1 Reply)
Discussion started by: zorro
1 Replies

2. UNIX for Dummies Questions & Answers

Difference between cat , cat > , cat >> and touch !!!

Hi Can anybody tell the difference between Difference between cat , cat > , cat >> and touch command in UNIX? Thanks (6 Replies)
Discussion started by: skyineyes
6 Replies

3. UNIX for Dummies Questions & Answers

Regarding redirection using cat.

The behavior of the following 2 operations is unexpected. K1 and K2 are files here :- 1) cat < K1 K2 The above operation should actually display contents of the both files. But it gives the contents of K2 only. How is that ? 2) cat > K1 K2 Above operation takes the contents of... (2 Replies)
Discussion started by: marconi
2 Replies

4. Shell Programming and Scripting

cat in the command line doesn't match cat in the script

Hello, So I sorted my file as I was supposed to: sort -n -r -k 2 -k 1 file1 | uniq > file2 and when I wrote > cat file2 in the command line, I got what I was expecting, but in the script itself ... sort -n -r -k 2 -k 1 averages | uniq > temp cat file2 It wrote a whole... (21 Replies)
Discussion started by: shira
21 Replies

5. Shell Programming and Scripting

Difficulty using "execute immediate" in shell - Sql script

Hello members, I get an unexpected "end of file" error while trying to execute the following piece of code in the bash / ksh shell. I'm assuming the problem is with using the "execute immediate statement" #! /bin/bash tname="table" for i in * do sqlstr="create table $tname$i as select... (3 Replies)
Discussion started by: novice82
3 Replies

6. Shell Programming and Scripting

How to check for Input Redirection in my script?

All, I have a requirement to write a script where I check for Input redirection when the script was executed, based on which I handle my logic. Below is the example: my.script #! /bin/ksh # Not sure how to frame the if condition below if ; then echo "Input Redirected from a file" ... (7 Replies)
Discussion started by: bharath.gct
7 Replies

7. Shell Programming and Scripting

STDOUT and STDERR redirection within a script

Hello all, I have a for loop executing in a script that I want to redirect STDOUT to screen and to file, while directing STDERR to the bit bucket. Here is the general sentax of what I'm doing: for i in thingy do some_command ${i} done 1>&1 | tee ${LOGFILE} 2> /dev/null What I am... (2 Replies)
Discussion started by: LinuxRacr
2 Replies

8. Shell Programming and Scripting

Input redirection script

Hi, #!/bin/bash while ; do rm -f /tmp/pipe mkfifo /tmp/pipe ./yuv4mpeg_to_v4l2 < /tmp/pipe & mplayer tom_and_jerry.mp4 -vf scale=480:360 -vo yuv4mpeg:file=/tmp/pipe sleep 65; done When I run this - after mplayer finishes playing video it says - Exiting... (End of... (2 Replies)
Discussion started by: ashokvpp
2 Replies

9. Shell Programming and Scripting

Input redirection within bash script

Hi, when I try to redirect input and the command is described as a string within an array redirection does not work. why? #!/bin/bash dir=("tail < ./hello.txt") tail < ./hello.txt #works ${dir} #does not work (2 Replies)
Discussion started by: heinzel
2 Replies
TMPFILE(3)						   BSD Library Functions Manual 						TMPFILE(3)

NAME
tempnam, tmpfile, tmpnam -- temporary file routines LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <stdio.h> FILE * tmpfile(void); char * tmpnam(char *str); char * tempnam(const char *tmpdir, const char *prefix); DESCRIPTION
The tmpfile() function returns a pointer to a stream associated with a file descriptor returned by the routine mkstemp(3). The created file is unlinked before tmpfile() returns, causing the file to be automatically deleted when the last reference to it is closed. The file is opened with the access value 'w+'. The tmpnam() function returns a pointer to a file name, in the P_tmpdir directory, which did not reference an existing file at some indeter- minate point in the past. P_tmpdir is defined in the include file <stdio.h>. If the argument s is non-NULL, the file name is copied to the buffer it references. Otherwise, the file name is copied to a static buffer. In either case, tmpnam() returns a pointer to the file name. The buffer referenced by s is expected to be at least L_tmpnam bytes in length. L_tmpnam is defined in the include file <stdio.h>. The tempnam() function is similar to tmpnam(), but provides the ability to specify the directory which will contain the temporary file and the file name prefix. The environment variable TMPDIR (if set), the argument tmpdir (if non-NULL), the directory P_tmpdir, and the directory /tmp are tried, in the listed order, as directories in which to store the temporary file. The argument prefix, if non-NULL, is used to specify a file name prefix, which will be the first part of the created file name. tempnam() allocates memory in which to store the file name; the returned pointer may be used as a subsequent argument to free(3). RETURN VALUES
The tmpfile() function returns a pointer to an open file stream on success, and a NULL pointer on error. The tmpnam() and tempnam() functions return a pointer to a file name on success, and a NULL pointer on error. ERRORS
The tmpfile() function may fail and set the global variable errno for any of the errors specified for the library functions fdopen(3) or mkstemp(3). The tmpnam() function may fail and set errno for any of the errors specified for the library function mktemp(3). The tempnam() function may fail and set errno for any of the errors specified for the library functions malloc(3) or mktemp(3). SEE ALSO
mkstemp(3), mktemp(3) STANDARDS
The tmpfile() and tmpnam() functions conform to ANSI X3.159-1989 (``ANSI C89''). All described functions also conform to IEEE Std 1003.1-2001 (``POSIX.1''), albeit the tempnam() and tmpnam() functions have been marked as obsolete in the IEEE Std 1003.1-2008 (``POSIX.1'') revision. BUGS
These interfaces are provided for AT&T System V UNIX and ANSI compatibility only. The mkstemp(3) interface is strongly preferred. SECURITY CONSIDERATIONS
There are four important problems with these interfaces (as well as with the historic mktemp(3) interface). First, there is an obvious race between file name selection and file creation and deletion: the program is typically written to call tmpnam(), tempnam(), or mktemp(3). Sub- sequently, the program calls open(2) or fopen(3) and erroneously opens a file (or symbolic link, or fifo or other device) that the attacker has placed in the expected file location. Hence mkstemp(3) is recommended, since it atomically creates the file. Second, most historic implementations provide only a limited number of possible temporary file names (usually 26) before file names will start being recycled. Third, the AT&T System V UNIX implementations of these functions (and of mktemp(3)) use the access(2) system call to determine whether or not the temporary file may be created. This has obvious ramifications for setuid or setgid programs, complicating the portable use of these interfaces in such programs. Finally, there is no specification of the permissions with which the temporary files are created. This implementation of tmpfile() does not have these flaws, and that of tmpnam() and tempnam() only have the first limitation, but portable software cannot depend on that. In particular, the tmpfile() interface should not be used in software expected to be used on other systems if there is any possibility that the user does not wish the temporary file to be publicly readable and writable. A link-time warning will be issued if tmpnam() or tempnam() is used, and advises the use of mkstemp() instead. BSD
April 30, 2010 BSD
All times are GMT -4. The time now is 10:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy