How to tell php to read shell?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to tell php to read shell?
# 1  
Old 04-05-2019
How to tell php to read shell?

.... Solved....
..
..

Hello,
I've read couples of similar threads to my question and I strongly believe that I am doing something wrong. What I'm trying to do is to process data with php. It reads data from shell script.
Everything goes well but at the end it does not print what it reads from shell .
I run it from a shell like php test.php $line with while read line loop

test.php
Code:
<?php
foreach($argv as $sProcess) {
   $i++;
$name = parse_str($argv[1]);
..
..
..
$redirect = 'http://xx.yy.zz/' . '"$name"' . ;

Lets say, if the string is "main.html", it redirects to
http://xx.yy.zz/"$name"
What I expect to get it:
http://xx.yy.zz/main.html

What is my fault?

Last attempt:
If I change the last line like below, nothing changes:
Code:
$redirect = 'http://xx.yy.zz/' . '"$sProcess"'.;

Solution:
Have just removed double quotes, put single quote into correct position and it's okay now.
Code:
$redirect = 'http://xx.yy.zz/' . $name . ';

Thank you
Boris

Last edited by baris35; 04-05-2019 at 04:56 PM..
This User Gave Thanks to baris35 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Smarter way to read $1 $2 in php

Hello, I am running under ubuntu14.04 with php5. When I run below php, it creates a token, then adds axaxax and bxbxbx into pc database, and at last, kills created token. What I am trying to do is to add userid and password read from a file. I do not wish to enter username and password manually.... (3 Replies)
Discussion started by: baris35
3 Replies

2. Shell Programming and Scripting

Php script read from $1

Hello, I am trying to inject data extracted via php-json to sql database but unable to run it in loop mode. It is working just for one data, then stops. If it's necessary, I can share the complete php file. test.php <?php include_once 'imdb.class.php'; //mysql config. $servername =... (4 Replies)
Discussion started by: baris35
4 Replies

3. UNIX for Dummies Questions & Answers

Shell script to read lines in a text file and filter user data Shell Programming and Scripting

sxsaaas (3 Replies)
Discussion started by: VikrantD
3 Replies

4. Shell Programming and Scripting

While read line in shell

Guys, I have a requirement like below my cfg file(sam.cfg) has path=/u/sample/test/ path=/u/sample1/test1/ path=/u/sample2/test2/ days=10 file=*.log My script is below, #!/bin/sh ./u/sample/sam.cfg while read line do find $path -name "$file" -mtime +$days -exec ls -la... (2 Replies)
Discussion started by: AraR87
2 Replies

5. Shell Programming and Scripting

read a line using c shell

Hi all, I am using csh to read a line from the terminal. I was told to use $< like the following in the terminal: set name = $< then I write a line: James Bond then I look at the value of 'name': echo $name it is always 'James'. Although the textbook tells me that $< read a... (2 Replies)
Discussion started by: lionheartyoung
2 Replies

6. Shell Programming and Scripting

read -p "prompt text" foo say "read: bad option(s)" in Bourne-Shell

Hallo, i need a Prompting read in my script: read -p "Enter your command: " command But i always get this Error: -p: is not an identifier When I run these in c-shell i get this error /usr/bin/read: read: bad option(s) How can I use a Prompt in the read command? (9 Replies)
Discussion started by: wiseguy
9 Replies

7. Programming

read arguments from shell

I have to write a C program using sys call (read, no fread) to read from shell all the parameters, without know how many are them. I tryed in some ways, but I have no success. Any Idea? Can I use read to read from stdin? (1 Reply)
Discussion started by: DNAx86
1 Replies

8. Shell Programming and Scripting

how to read a file using shell ??

Hello i have a file in directory which has some values like this lets assume the file is $p ttry_rtyy_trree and i am using a file as an input as ($Y) in a shell once i start the shell it should read the file $p and $Y once those lines are matched in $Y i want to take a copy of that ... (7 Replies)
Discussion started by: ranga27
7 Replies

9. Shell Programming and Scripting

how to read in shell

how to read 3rd entry of 6th line from the bottom in /etc/passwd file using shell script (10 Replies)
Discussion started by: useless79
10 Replies

10. Shell Programming and Scripting

When does a shell read into memory?

I don't know how to ask this clearly, so I'll try my best... At what point does a shell script stop reading from a file, and begin using the buffered script? Hopefully, this example will shed some light: #!/usr/bin/ksh value="" until ; do sleep 10 print "What is your value?" #print... (5 Replies)
Discussion started by: LivinFree
5 Replies
Login or Register to Ask a Question