piping output from PHP file into variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting piping output from PHP file into variable
# 1  
Old 12-08-2008
piping output from PHP file into variable

Hi.

I have a script like so:
Code:
#!/bin/bash

download='php /var/www/last.php'
echo $download
if $download

How 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 either a 1 or 0).

Thanks.
# 2  
Old 12-08-2008
so you wanna catch the return code(status code) taht is "$?" ??
Code:
php /var/www/last.php
echo $?
if [ $? -eq 0 ]

# 3  
Old 12-08-2008
yeh, its working now, thanks anyway!

Code:
download=$(php /var/www/last.php) 

if test $download -eq 1

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help piping a value to a variable

Hey Guys. Below is the code I am using to pipe a value into a variable. When I tried it says the following xargs: :HEX:: No such file or directory Not sure what it means. Can anyone please help me figure this out. Below is the code I am using. (It echo's out just fine) sed -n... (1 Reply)
Discussion started by: eldan88
1 Replies

2. 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

3. 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

4. Shell Programming and Scripting

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...... (6 Replies)
Discussion started by: ninjaaron
6 Replies

5. Fedora

Piping output of "top" to a text file

I would like to pipe "top -n" to a text file, but I get an error: top: cannot open /dev/kmem kvm_open: Permission denied I am a non-root user. If I could find a way to get this type of output: "Memory: 2048M real, 1516M free, 4099M swap free" into a text file, I could further automate... (13 Replies)
Discussion started by: safraser
13 Replies

6. 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

7. Shell Programming and Scripting

Piping to a file and setting filename using a variable

Hi all, I would like to send the output of a line in a ksh script to a file, but I need to name the file using a predefined variable: ls -l > $MYVAR.arc But what is the correct syntax for achieving this? I can't seem to find the correct syntax for giving the file an extension. Any... (8 Replies)
Discussion started by: mandriver
8 Replies

8. 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

9. 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

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