Sponsored Content
Top Forums Shell Programming and Scripting Can't Output Piped Perl In-line command to a File Post 302770218 by ConcealedKnight on Thursday 14th of February 2013 08:24:06 PM
Old 02-14-2013
Can't Output Piped Perl In-line command to a File

Hello,

I'm pretty stumped, and I don't know why I am not able to redirect the output to the 'graphme' file with the command below in Fedora 18.

Code:
tcpdump -l -n -t "tcp[13] == 18" | perl -ane '($s,$j)=split(/,/,$F[7],2); print "$s\n";' > graphme

In case you're wondering, I was following the example from the Graphing Initial Sequence Numbers section in Linux Administration: A Beginner's Guide 5th Edition with a little modification as I only wanted to get the first syn value from the tcpdump output.

I'm currently using tcpdump version 4.3, and perl version 5.16.2. I don't know if the version makes a difference here. I would appreciate an explanation why I couldn't redirect the output to the file but was able to redirect it to another tty or current terminal using '> /dev/tty2'.

Thanks in advance for your help.

EDIT: Since there is no response, I thought this may help those who may be afraid to execute the above command, which is pretty harmless since I was only capturing packets. This is the output from the `tcpdump -l -n -t "tcp[13] == 18"' command:
Code:
IP 50.22.206.133.http > 10.0.2.109.44777: Flags [S.], seq 3029681720, ack 19750303, win 11584, options [mss 1460,sackOK,TS val 3311545446 ecr 3361031,nop,wscale 9], length 0
IP 199.38.164.156.http > 10.0.2.109.33959: Flags [S.], seq 4217910485, ack 777386666, win 4380, options [mss 1460,nop,wscale 0,nop,nop,TS val 3690041151 ecr 3361175,sackOK,eol], length 0
IP 74.125.226.249.http > 10.0.2.109.45763: Flags [S.], seq 2645889525, ack 79909840, win 62392, options [mss 1430,sackOK,TS val 1192032006 ecr 3361277,nop,wscale 6], length 0

When I piped it to perl, I expected to extract the following output from the above command:
Code:
3029681720
4217910485
2645889525


Last edited by ConcealedKnight; 02-14-2013 at 11:43 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl... how to tell if a piped command is still running?

I'm using the fabulous perl. I need a way to tell when a piped call to "open" has completed. Can I do this with a command like <ShellPipe> ?? Reason behind this: I'm trying to write a backup script in perl! This script will download a certain file from my web server, to my computer. Now,... (0 Replies)
Discussion started by: boytheo
0 Replies

2. Shell Programming and Scripting

Identify matching data in a file and output to original line, in perl

Hi, I haven't done this for awhile, and further, I've never done it in perl so I appreciate any help you can give me. I have a file of lines, each with 5 data points that look like this: AB,N,ALLIANCEBERNSTEIN HLDNG L.P,AB,N ALD,N,ALLIED CAPITAL CORPORATION,ALD,N AFC,N,ALLIED CAPITAL... (4 Replies)
Discussion started by: Pcushing
4 Replies

3. Shell Programming and Scripting

script output should be piped to a file

hi i have a script named mount.sh under the location /data/scripts/ in my aix box i want this script this to be run everyday morning at 04:45 AM and the output of the script should be piped to a file how to do this ? (3 Replies)
Discussion started by: samsungsamsung
3 Replies

4. Shell Programming and Scripting

Insert shell command into first line of output file

How can I insert the command executed on the shell into the first line of my output file? For example if I execute; zcat *.gz |grep “User5501” > users.out How can I make my users.out look like; zcat *.gz |grep “User5501” > users.out User5501 PA User5501 UA User5501 ZA... (3 Replies)
Discussion started by: lewk
3 Replies

5. UNIX for Dummies Questions & Answers

Finding the modified timestamp of files from the piped output of du command

Version Info +++++++++++++++ RHEL 5.4 Since ls command lists file sizes in Bytes which can be long I use du command like below. I have run the du command for the below files as shown below. But I want pipe this output to ls command just to see the modified timestamp for these files. ... (7 Replies)
Discussion started by: kraljic
7 Replies

6. Shell Programming and Scripting

sed command to replace a line in a file using line number from the output of a pipe.

Sed command to replace a line in a file using line number from the output of a pipe. Is it possible to replace a whole line piped from someother command into a file at paritcular line... here is some basic execution flow.. the line number is 412 lineNo=412 Now i have a line... (1 Reply)
Discussion started by: vivek d r
1 Replies

7. Shell Programming and Scripting

Modifying file from command line using Perl

Hi all, I am having a slight issue updating a file using perl from the command line I need some help with. The item is: DATA_FILE_TYPE=FULL When I run the below command /usr/bin/perl -p -i -e "s/DATA_FILE_TYPE=/DATA_FILE_TYPE=APPEND/g" processfile.cfg It looks to be... (2 Replies)
Discussion started by: kstevens67
2 Replies

8. Shell Programming and Scripting

Print line number from piped output

i need to do something like this: script.sh #!/bin/sh echo "hello" echo "My First name is John" echo "My Last name is Smith" echo "I am here to save you a lot of work" sed -n 4,5p $0 i dont want to run the script. i just want to pull out specific line from it. so the logic here... (5 Replies)
Discussion started by: SkySmart
5 Replies

9. Shell Programming and Scripting

Perl command line option '-n','-p' and multiple files: can it know a file name of a printed line?

I am looking for help in processing of those options: '-n' or '-p' I understand what they do and how to use them. But, I would like to use them with more than one file (and without any shell-loop; loading the 'perl' once.) I did try it and -n works on 2 files. Question is: - is it possible to... (6 Replies)
Discussion started by: alex_5161
6 Replies

10. Shell Programming and Scripting

Use cut output as variable piped awk command

Hi, I would like use the output of my cut command as a variable in my following awk command. Here's what I've written. cut -f1 info.txt | awk -v i=xargs -F'' '{if($6 == $i) print $20}' summary.txt Where obviously the 'xargs' doesn't do what I want. How can I pass my cut result to my awk... (3 Replies)
Discussion started by: heyooo
3 Replies
shell(1F)							   FMLI Commands							 shell(1F)

NAME
shell - run a command using shell SYNOPSIS
shell command [command] ... DESCRIPTION
The shell function concatenate its arguments, separating each by a space, and passes this string to the shell ($SHELL if set, otherwise /usr/bin/sh). EXAMPLES
Example 1: A sample output of shell command. Since the Form and Menu Language does not directly support background processing, the shell function can be used instead. `shell "build prog > /dev/null &"` If you want the user to continue to be able to interact with the application while the background job is running, the output of an exe- cutable run by shell in the background must be redirected: to a file if you want to save the output, or to /dev/null if you don't want to save it (or if there is no output), otherwise your application may appear to be hung until the background job finishes processing. shell can also be used to execute a command that has the same name as an FMLI built-in function. NOTES
The arguments to shell will be concatenate using spaces, which may or may not do what is expected. The variables set in local environments will not be expanded by the shell because "local" means "local to the current process." ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
sh(1), attributes(5) SunOS 5.10 5 Jul 1990 shell(1F)
All times are GMT -4. The time now is 02:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy