Sponsored Content
Full Discussion: Output redirection
Top Forums UNIX for Dummies Questions & Answers Output redirection Post 302494248 by mfruiz34 on Sunday 6th of February 2011 12:28:05 PM
Old 02-06-2011
Output redirection

Hello i am trying to write a script that will redirect the output to a certain file. Here is the code so far:

Code:
#!/bin/bash
ps -e | sort | more > psfile

When I execute the script nothing happens since i assume the output was redirected to the file called psfile. When I try to look at the psfile, I get the following:

Code:
[root@localhost manny]# psfile
./psfile: line 1: 10: command not found
./psfile: line 2: 1: command not found
./psfile: line 3: 11: command not found
./psfile: line 4: 1249: command not found
./psfile: line 5: 1250: command not found
./psfile: line 6: 1310: command not found
./psfile: line 7: 140: command not found
./psfile: line 8: 141: command not found

Am I missing something here? Do I have to create the file "psfile" before running the script?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Redirection of output (for logging)

Hi, Currently I'm working on a lenghty script so I figured it would be useful to create a logfile so that output that is displayed on the users screen is also stored in the log file for later reference...... kinda like the whole point of a log file! Anyway, I was just wondering if there was an... (3 Replies)
Discussion started by: _Spare_Ribs_
3 Replies

2. UNIX for Dummies Questions & Answers

output redirection in scripts

I am trying to write a script that will remove any line in 2 given text files starting with '-'. the output should be to the second file. this is what I tried: #!/bin/csh -f cat $1 $2 | grep -v '^-' > $2 the problem is the after executing the script, file2 contains only the lines from... (7 Replies)
Discussion started by: stewie griffin
7 Replies

3. Shell Programming and Scripting

output and error redirection

hi :) if condition >&- 2>&- Can anybody explain the redirection in above command Thanks in advance (1 Reply)
Discussion started by: jpriyank
1 Replies

4. Shell Programming and Scripting

redirection and output

I'm redirecting the output of a command to a logfile, however, if the user is on a terminal I would also like the output to be displayed on the screen. tar tvf some_tarfile >Logfile if the user is on a term then have the output to the Logfile and also be displayed on the screen at the same... (2 Replies)
Discussion started by: nck
2 Replies

5. Shell Programming and Scripting

Redirection output

Hi there I have a script that runs but it outputs everything onto the screen instead of a file. I've tried using the > outputfile.txt however all it does is dump the output to the screen and creates an outputfile.txt but doesn't put anything in that file. Any help would be appreciated ... (6 Replies)
Discussion started by: kma07
6 Replies

6. Shell Programming and Scripting

Output redirection

We have an application here that does some table queries and then prints the result on screen. I do not have the code of this application (which i will just call "queryCommand"), but what it does is that you call it with some parameters and it prints some info about the query and then the... (5 Replies)
Discussion started by: jolateh
5 Replies

7. Shell Programming and Scripting

Issue with output redirection

Hi, I am using AIX server. I have a korn shell script where in I am redirecting a line to a file in a while loop: while read line do outputline=$line; echo $outputline >> "./temp/exec_list_"$ETL_JOB_RUN"_temp" done < ./temp/exec_list_$ETL_JOB_RUN Sometimes, when the CPU... (2 Replies)
Discussion started by: pmonika
2 Replies

8. Shell Programming and Scripting

Redirection of ls -l output

Hi I am making a script where i want to redirect the output of ls -l to a file Example #ls -l fil1.txt > /opt/temp/a.txt ac: No such file or directory I want to capture output of this command like here output is ac: No such file or directory can anyone help (4 Replies)
Discussion started by: anish19
4 Replies

9. Shell Programming and Scripting

output redirection

Hi all I was wondering if there was a slicker way of doing this without the file - awk '{print $2}' FS=":" "${FILE}" > "${TMPFILE}" { read M_GRP_ID || m_fail 1 "Error: Read failed 1 (${FUNCNAME})" read M_GRP_WAIT || m_fail 1 "Error: Read failed 2 (${FUNCNAME})" }... (6 Replies)
Discussion started by: steadyonabix
6 Replies

10. Shell Programming and Scripting

For loop output redirection

Hi All, i have below for loop of which i am trying to redirect output in a file: for i in `/usr/sbin/ifconfig -a | awk '/flags/ {print $1}' | grep -v lo | sed 's/://g'` do ifconfig $i dhcp status done >> /tmp/logfile but instead the output is appearing as stdout on screen rather than... (12 Replies)
Discussion started by: omkar.jadhav
12 Replies
pstopnm(1)						      General Commands Manual							pstopnm(1)

NAME
pstopnm - convert a PostScript file into a portable anymap SYNOPSIS
pstopnm [-stdout] [-forceplain] [-help] [-llx s] [-lly s] [-landscape] [-portrait] [-nocrop] [-pbm |-pgm |-ppm] [-urx s] [-ury s] [-ver- bose] [-xborder n] [-xmax n] [-xsize f] [-yborder f] [-ymax n] [-ysize n] psfile[.ps] DESCRIPTION
Reads a PostScript file as input. Produces PBM, PGM, or PPM files as output. This program simply uses GhostScript to render a PostScript file with its PNM device drivers. If you don't have GhostScript installed (invoked by a gs command), or the version you have installed was not built with the relevant PNM device drivers, pstopnm will fail. You can see if you have the proper environment by issuing the command gs --help . If it responds and lists under "Available Devices" pbm, pbmraw, pgm, pgmraw, pnm, pnmraw, ppm, or ppmraw, you're in business. pstopnm does not use the Netpbm libraries to generate the output files, so may not be entirely consistent with most Netpbm programs. psfile[.ps] is the name of the input file. .pstopnm will add the ps to the end of the name you specify if no file exists by the exact name you specify, but one with added does. Use - to indicate Standard Input. If you use the -stdout option, pstopnm outputs images of all the pages as a multi-image file to Standard Output. Otherwise, pstopnm cre- ates one file for each page in the Postscript document. The files are named as follows: If the input file is named psfile.ps, the name of the files will be psfile001.ppm, psfile002.ppm, etc. The filetype suffix is .ppm, .pgm, or .pbm, depending on which kind of output you choose with your invocation options. If the input file name does not end in .ps, the whole file name is used in the output file name. For example, if the input file is named psfile.old, the output file name is psfile.old001.ppm, etc. Note that the output file selection is inconsistent with most Netpbm programs, because it does not default to Standard Output. This is for historical reasons, based on the fact that the Netpbm formats did not always provide for a sequence of images in a single file. Each output file contains the image of a rectangular part of the page to which it pertains. The selected area will always be centered in the output file, and may have borders around it. The image area to be extracted from the PostScript file and rendered into a portable anymap is defined by four numbers, the lower left corner and the upper right corner x and y coordinates. These coordinates are usually specified by the BoundingBox comment in the PostScript file header, but they can be overridden by the user by specifying one or more of the following options: -llx, -lly, -urx, and -ury. The presence and thickness of a border to be left around the image area is controlled by the use of the options -xborder and -yborder. If pstopnm does not find BoundingBox parameters in the input, and you don't specify image area coordinates on the command line, pstopnm uses default values. If your input is from Standard Input, pstopnm does not use the Bound- ingBox parameters (due to the technical difficulty of extracting that information and still feeding the file to Ghostscript), so you either have to specify the image area coordinates or take the default. Unless you specify both output file width and height, via the -xsize and -ysize options, pstopnm maps the document into the output image by preserving its aspect ratio. It has been reported that on some Postscript Version 1 input, Ghostscript, and therefore pstopnm, produces no output. To solve this prob- lem, you can convert the file to Postscript Version 3 with the program ps2ps. It is reported that the program pstops does not work. OPTIONS
-forceplain forces the output file to be in plain (text) format. Otherwise, it is in raw (binary) format. See pbm(1), etc. -llx bx selects bx as the lower left corner x coordinate (in inches). -lly by selects by as the lower left corner y coordinate (in inches). -landscape renders the image in landscape mode. -portrait renders the image in portrait mode. -nocrop does not crop the output image dimensions to match the PostScript image area dimensions. -pbm -pgm -ppm selects the format of the output file. By default, all files are rendered as portable pixmaps (ppm format). -stdout causes output to go to Standard Output instead of to regular files, one per page (see description of output files above). Use pnm- split to extract individual pages from Standard Output. -urx tx selects tx as the upper right corner x coordinate (in inches). -ury ty selects ty as the upper right corner y coordinate (in inches). -verbose prints processing information to stdout. -xborder frac specifies that the border width along the Y axis should be frac times the document width as specified by the bounding box comment in the PostScript file header. The default value is 0.1. -xmax xs specifies that the maximum output image width should have a size less or equal to xs pixels (default: 612). -xsize xsize specifies that the output image width must be exactly xs pixels. -yborder frac specifies that the border width along the X axis should be frac times the document width as specified by the bounding box comment in the PostScript file header. The default value is 0.1. -ymax ys specifies that the maximum output image height should have a size less or equal to ys pixels (default: 792). -ysize ys specifies that the output image height must be exactly ys pixels. BUGS
The program will produce incorrect results with PostScript files that initialize the current transformation matrix. In these cases, page translation and rotation will not have any effect. To render these files, probably the best bet is to use the following options: pstopnm -xborder 0 -yborder 0 -portrait -nocrop file.ps Additional options may be needed if the document is supposed to be rendered on a medium different from letter-size paper. SEE ALSO
gs(1), pstofits(1), pnmtops(1), psidtopgm(1), pbmtolps(1), pbmtoepsi(1), pnmsplit(1) COPYRIGHT
Copyright (c) 1992 Smithsonian Astrophysical Observatory PostScript is a Trademark of Adobe Systems Incorporated. AUTHOR
Alberto Accomazzi, WIPL, Center for Astrophysics. 28 June 2000 pstopnm(1)
All times are GMT -4. The time now is 10:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy