473,320 Members | 2,080 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

how to get value from php to shell command

43
this is my code:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $name = POST_["grib_name"];
  3.  
  4. $output2 = shell_exec('Gribinfo  $shell_name' );
  5. echo "<pre>$output2</pre>";
  6. ?>
  7.  
here , I wanna the $shell_name, which is in shell command, get the value of $name which is in php.
Anyone knows how to do it ???
Thanks a million !
Tanya
May 21 '07 #1
5 2002
Motoma
3,237 Expert 2GB
this is my code:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $name = POST_["grib_name"];
  3.  
  4. $output2 = shell_exec('Gribinfo  $shell_name' );
  5. echo "<pre>$output2</pre>";
  6. ?>
  7.  
here , I wanna the $shell_name, which is in shell command, get the value of $name which is in php.
Anyone knows how to do it ???
Thanks a million !
Tanya

Two ways to do it: use double quotes ($output2 = shell_exec("Gribinfo $name");) or string concatenation ($output2 = shell_exec('Gribinfo '.$name);)
May 21 '07 #2
tanyali
43
Two ways to do it: use double quotes ($output2 = shell_exec("Gribinfo $name");) or string concatenation ($output2 = shell_exec('Gribinfo '.$name);)
Thanks for answering,
I tried both, but neither works.

when I use
$output2 = shell_exec('Gribinfo $name');
the result means no value of $name passed in.

when I use
$output2 = shell_exec("Gribinfo $name"); and
$output2 = shell_exec('Gribinfo '.$name);
nothing come out.
May 22 '07 #3
Motoma
3,237 Expert 2GB
This line is wrong.
Expand|Select|Wrap|Line Numbers
  1. $name = POST_["grib_name"];
  2.  
It should be this.
Expand|Select|Wrap|Line Numbers
  1. $name = $_POST['grib_name'];
  2.  
May 22 '07 #4
tanyali
43
This line is wrong.
Expand|Select|Wrap|Line Numbers
  1. $name = POST_["grib_name"];
  2.  
It should be this.
Expand|Select|Wrap|Line Numbers
  1. $name = $_POST['grib_name'];
  2.  

I wrote it right before , it was $_POST["grib_name"];

and nothing wrong with your two ways,
the problem is :
Each time you call shell_exec, it operates in a completely new shell.
I added this :
chdir("/home/.../grib_downloaded");
to specify the directory again. it works !
thanks for your help !
Tanya
May 22 '07 #5
Motoma
3,237 Expert 2GB
I wrote it right before , it was $_POST["grib_name"];

and nothing wrong with your two ways,
the problem is :
Each time you call shell_exec, it operates in a completely new shell.
I added this :
chdir("/home/.../grib_downloaded");
to specify the directory again. it works !
thanks for your help !
Tanya
Glad everything worked out well. Come back any time you have a problem.
May 22 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: Freeserve | last post by:
Hi, I am trying to pass a value from an ASP script to a VB application running on the server. The only way I have got this to work is by using a file, which is too slow. I tried using DDE but...
8
by: Siemel Naran | last post by:
Hi. I'm writing a command shell that reads commands from standard input. At this point I have the command in a std::string. Now I want to execute this command in the shell. From the Borland...
6
by: Lauren Wilson | last post by:
Hi folks, In an A2K app, I have attempted to use the following command in some VBA code with IDENTICAL results with every single version of the following: Shell "outlook.exe", vbHide Shell...
1
by: VRWC | last post by:
Hello dear people, In an A2K app, I have attempted to use the following command in some VBA code with IDENTICAL results with every single version of the following: Shell "outlook.exe", vbHide...
6
by: CMG | last post by:
I am writing a little code to associate an extention with my program. And as far as i can see, i need to do the following: Public Function associatefile(ByVal FILE_EXTENTION_TO_ASSOCIATE As...
2
by: micahstrasser | last post by:
I have been trying for days to send a command to the command prompt through the shell() function in vb.net. For some reason it is not working. Here is the code: Private Sub Button1_Click(ByVal...
13
by: vashwath | last post by:
Hi all, To test the return value of system I wrote 2 programs which are shown below. Program 1: #include <stdio.h> #include <stdlib.h> int main(void)
25
by: dennijr | last post by:
ok, shell always used to be easy for me, now its starting to get annoying cause i dont know wats wrong heres the simplist code possible: Private Sub IExplorer_Click() a = Shell("C:\Program...
3
by: Max Vit | last post by:
I have come across a strange issue whilst trying to use a shell command call from Access and have spent some time trying to figure this out but can't find the cause as yet. The issue is: I need...
7
by: Samuel A. Falvo II | last post by:
I have a shell script script.sh that launches a Java process in the background using the &-operator, like so: #!/bin/bash java ... arguments here ... & In my Python code, I want to invoke...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.