need help piping the output from an app... uh, yeah...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need help piping the output from an app... uh, yeah...
# 1  
Old 10-02-2011
[SOLVED]need help piping the output from an app... uh, yeah...

Ok, so there is a perl script that runs as a server, on my local host. It tells me which port to use. I want to pipe that output into my browser so I can do the whole thing with a single command. The problem is, I think, that the program doesn't actually exit cause it's running a server, so... so I dunno. Anyway the output looks like this:
Code:
Startup complete. You may now point your browser at this address: http://127.0.0.1:8890

... though obviously the port can be different. so, when I run 'foo.pl|grep http,' I just get the line with address, which is exactly what I want. I've tried a few things to get my browser to open this. So, at first I was trying this:
Code:
link=`foo.pl|grep http` firefox "$link"

This doesn't work. It seems to start the server, but I don't get any output out of, so it's useless unless I check my ports manually. The browser doesn't start either. Then I tried this; cutting out the middle-man, as it were:
Code:
/usr/local/diogenes/perl/diogenes-server.pl|grep http|firefox

This starts the sever and the browser, but it doesn't actually point the browser at the server. not really sure what to try next. edit: bb is on the fritz right now or something. Formatting is really messed up

Last edited by ninjaaron; 10-02-2011 at 04:41 PM..
# 2  
Old 10-02-2011
Try this...

Code:
firefox `foo.pl | awk '{print $NF}'`

--ahamed
# 3  
Old 10-02-2011
Not doing it.
# 4  
Old 10-02-2011
whats the output of foo.pl | awk '{print $NF}?

An argument to firefox is working for me.
Try firefox "www.google.com". Is it opening a new browser with the given address?

--ahamed
# 5  
Old 10-02-2011
The output is:

Code:
address:
http://127.0.0.1:8888

The one with grep just outputs the address.

The problem is that the perl script doesn't exit (it maintians the server), so my bash script doesn't make it past that line. I tried it with an '&' but it breaks the syntax

And yes, firefox can be opened from the command line with a url (and I'm actually using uzbl-browser, but I didn't want it to throw anyone off).
# 6  
Old 10-02-2011
so, you mean to say, the foo.pl will never exit but displays the info on the screen?
If that is the case, then why not write the ouput to a file and then read the file & open the browser. Something like this

Code:
foo.pl >/tmp/foo.log & firefox `grep http /tmp/foo.log`

--ahamed
# 7  
Old 10-02-2011
I tried something similar earlier, but I had the grep before the '>,' which must have broken it.

This worked... well, it almost worked. It needs a moment for the output to be there from te browser, so I ended up with this:
Code:
foo.pl > /tmp/foo.log &
sleep .3
firefox `grep http /tmp/foo.log`

... and then a little something to kill the perl script when the browser closes.

Thanks!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Abnormality while piping tr command output to sed

i have a file seperated each line seperated by newline. For example alpha beta gamma i am trying to replace the newlines to "," but dont want , present at the end of the line so i am trying the below one liner . but not sure whats wrong but its not working cat myfile | tr -s '\n' ',' | sed... (9 Replies)
Discussion started by: chidori
9 Replies

2. Shell Programming and Scripting

Piping output of ls to a text file

Basically I was wondering if any of you know how to pipe the output of ls to a text file? so in my shell script one of the lines is ls but i want to pipe it into a file called directory listing. Cheers. I have tried ls | Directorylisting.txt but it keeps saying " line 7: DirectoryListing.txt:... (9 Replies)
Discussion started by: LinuxNubBrah
9 Replies

3. Shell Programming and Scripting

Piping output from a command into bash script

Hi all. I am using procmail to deliver an email to a script I am developing. Procmail delivers the email to the script on standard input. I imagine this is the same as piping input from a command into the script. Hence I've been testing my script by running echo 'test' | sms-autosend-backup.sh ... (2 Replies)
Discussion started by: akindo
2 Replies

4. Shell Programming and Scripting

Piping and assigning output to a variable in Perl

Hi All, I am trying to convert the below Csh code into Perl. But i have the following error. Can any expert help ? Error: ls: *tac: No such file or directory Csh set $ST_file = `ls -rt *$testid*st*|tail -1`; Perl my $ST_file = `ls -rt *$testid*st*|tail -1`; (10 Replies)
Discussion started by: Raynon
10 Replies

5. Shell Programming and Scripting

piping output from PHP file into variable

Hi. I have a script like so: #!/bin/bash download='php /var/www/last.php' echo $download if $downloadHow do I pipe the output of the php file into a variable, as when i run the if statement, it just echos the file output to the screen and does not actually consider the output (it will be... (2 Replies)
Discussion started by: daydreamer
2 Replies

6. Shell Programming and Scripting

piping oracle output to a file?

Hi All... Does anyone know how to pipe the output of a "select" statement from a call to Oracle to a file? ANy ideas woule be greatly appreciated! Code is as below... echo "producing CSV file 2..." sqlplus -s $username/$password@$database<<EOF set serveroutput on size 1000000 set... (13 Replies)
Discussion started by: satnamx
13 Replies

7. Shell Programming and Scripting

piping output of tail running in background

Not sure why this does not work in bash: tail -f err.log |& -bash: syntax error near unexpected token `&' I am attempting to continuously read a file that is being updated by doing a "tail -f" on the file and piping the output to stdin which can then be read by the next shell command Thnx (4 Replies)
Discussion started by: anuramdas
4 Replies

8. Shell Programming and Scripting

piping output to echo

Hi, I was wondering why ls * | echo does not print the contents of the directory to the screen? The way I see it, ls * returns a whole lot of information, and then we pipe all this info to echo, so surely it should all come to our screen! Is there a serious flaw in my understanding? ... (3 Replies)
Discussion started by: A1977
3 Replies

9. UNIX for Dummies Questions & Answers

piping the output of find command to grep

Hi, I did not understand why the following did not work out as I expected: find . -name "pqp.txt" | grep -v "Permission" I thought I would be able to catch whichever paths containing my pqp.txt file without receiving the display of messages such as "find: cannot access... Permisson... (1 Reply)
Discussion started by: 435 Gavea
1 Replies

10. Shell Programming and Scripting

Piping output to while read

Hi. Im using cat to output the contents of a file, then piping it to my while read loop.In this loop variables get assigned values. However when i try to use the variables outside the loop their values has been reset.I understand about subshells etc. but I have no idea how to "preserve" the... (3 Replies)
Discussion started by: Ultimodiablo
3 Replies
Login or Register to Ask a Question