LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-02-2014, 05:25 AM   #1
Pekeltje
LQ Newbie
 
Registered: Mar 2014
Posts: 6

Rep: Reputation: Disabled
Question Using bash script with PHP Exec with parameters


Hello,

First of all, im new here and i hope im posting this in the right section.
Also im pretty new with using Linux (Ubuntu)
Forgive me if i dont understand you.

Im using https://github.com/vysheng/tg to send Telegram messages from commandline, wich works, everything is installed correctly.

Now im trying to send messages from PHP using exec()
PHP Code:
function stuurbericht($naam,$bericht){
    
putenv("naam=$naam");
    
putenv("bericht=$bericht");
        
$output exec('./stuurbericht');
            echo 
$output;
}
stuurbericht('User_Name','Dit is een test'); 
When i var_dump it i get: ./telegram[0x40c64d]

When i use php /location/of/script/send.php it goes to the screen where i can send messsages, but doesnt send anything yet.

This is my bash script:
Code:
naam=$naam
bericht=$bericht

echo $naam
echo $bericht


cd /location/to/telegram/tg-master
./telegram -k tg.pub
msg $naam $bericht
Jordy
 
Old 03-03-2014, 04:09 AM   #2
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,591

Rep: Reputation: 145Reputation: 145
So you use a web frontend to write the message?
I am not sure but maybe this change makes a difference?

$output = exec('/full/path/to/stuurbericht');
 
Old 03-03-2014, 05:59 AM   #3
Smokey_justme
Member
 
Registered: Oct 2009
Distribution: Slackware
Posts: 534

Rep: Reputation: 203Reputation: 203Reputation: 203
First, try using passthru while developing to get the full output (exec only returns the last line).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] bash script parameters and logic asistant Programming 17 04-19-2012 07:39 AM
exec() in php script not working magicalshashank31 Programming 1 12-24-2011 10:31 AM
[SOLVED] bash script sed -r -i and -e parameters charu Programming 10 05-06-2011 06:28 AM
Passing parameters to bash script Kamikazee Programming 4 10-01-2005 06:41 AM
Pass Parameters to php from bash iman00b Linux - Newbie 2 09-09-2004 05:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration