ffmpeg_concat is not running from shell_exec() function? - ffmpeg

command is running on CLI on Linux.
ffmpeg-concat -t circleopen -d 750 -o /var/www/html/testing_video/huzzah.mp4 /var/www/html/testing_video/1.mp4 /var/www/html/testing_video/2.mp4 /var/www/html/testing_video/3.mp4 2>&1
Perfectly working on CLI. But when i used with the shell_exec command from a php file it gives an error.
failed to create OpenGL context
at module.exports (/usr/lib/node_modules/ffmpeg-concat/lib/context.js:24:11)
at module.exports (/usr/lib/node_modules/ffmpeg-concat/lib/render-frames.js:19:21)
at module.exports (/usr/lib/node_modules/ffmpeg-concat/lib/index.js:53:32)
at
Anyhow i debug the code function is calling and the parameters width and height is passing but still returning null.
Node version:v8.11.3

Related

how to execute bash script with options in Robot Framework

I want to execute some kind of bash script in Robot Framework.
In terminal I use that command:
bash /home/Documents//script.sh --username=root --password=hello --host=100.100.100.100 --port=400 - --data='{"requestId":1,"parameters":{"name":"check","parameters":{"id":"myID"}}}'
and it works
In robot script I try with:
Running script
${result} = Run Process bash /home/Documents//script.sh "username\=root" "password\=hello" "host\=100.100.100.100" "port\=400" "data\='{"requestId":1,"parameters":{"name":"check","parameters":{"id":"myID"}}}'" shell=True stdout=stdout.txt
Log To Console ${result}
Log ${result}
Log ${result.stdout}
Log ${result.stderr}
But I get Missing required arguments: username, password, host, port.
Process doesn't recognise arguments.
How to pass script arguments in Robot Framework with Process Library?
Please show examples, I checked already doc in Process Library for Specifying command and arguments but I don't understand it.
After the night I found solution:
Running script
${result} = Run Process bash /home/Documents//script.sh username\=root password\=hello host\=100.100.100.100 port\=400 data\='{"requestId":1,"parameters":{"name":"check","parameters":{"id":"myID"}}}' shell=True stdout=stdout.txt
Options should be unquoted but = should be escaped with \

Kubernetes postStart lifecycle hook exited with 7

I have a simple bash script to execute at postStart, but i get an error which is not informative at all:
Exec lifecycle hook ([/bin/bash -c sleep 30;/xcom/scripts/sidecar_postStart.sh]) for Container "perfcibuddy" in Pod "xcomapp-597fb859c5-6r4g2_ns(412852d1-5eea-11ea-b641-0a31ddb9a71e)" failed - error: command '/bin/bash -c sleep 120;/xcom/scripts/sidecar_postStart.sh' exited with 7: , message: ""
The sleep is there because I got a tip that there might be a race condition, that the script is not in place at the time Kubernetes calls it.
And if I log into the container I can execute the script from the shell without any problem.
The script is just doing a simple curl call (IP obviously sanitized):
# ----------------------------------------------------------------------------
# Script to perform postStart lifecycle hook triggered actions in container
# ----------------------------------------------------------------------------
# -------------------------------------------[ get token from Kiam server ]---
role_name=$( curl -s http://1.1.1.1/latest/meta-data/iam/security-credentials/ )
curl -s http://1.1.1.1/latest/meta-data/iam/security-credentials/${role_name}
I tried numerous form to set the command in the template (everything in quotes, with && instead of ;), this is the current one:
exec:
command: [/bin/bash, -c, "sleep 120;/xcom/scripts/sidecar_postStart.sh"]
What could be the problem here?
Curl exit code 7 is generally “unable to connect” so your IP is probably wrong or the kiam agent is not set up correctly.

Bash function to automate curl POST authentication not executing as intended

I am using Ubuntu bash shell on a windows machine and i am trying to create a function to test my endpoints of a spring application. First i must authenticate with the server via the following curl command. The output of the statement run is below.
$> curl -i -X "POST" -d"${auth}" -H"${contentType}" "${host}/login"
When i copy and paste this command into a function it seems to blow up leading to non-execution of curl as intended which should have the same output as above.
$> function springlogin(){curl -i -X "POST" -d"${auth}" -H"${contentType}" "${host}/login";};
$> springlogin
What am i missing here? Is this due to some variable expansion im not aware of? Or something else entirely.
My end goal would be to use the output of this function and use it to authorize my endpoint api calls if i happen to be on my command line.
Thanks to Gordon Davisson i figured it out. This is something that we do at work but i didn't think to do it in my home code. I need to unset the function in my profile before i declare it again.
unset springlogin
function springlogin(){curl -i -X "POST" -d"${auth}" -H"${contentType}" "${host}/login";};

Running a PHP CLI Script from a PHP Application

I have a php file which needs to be executed in CLI from my Php application which runs on CodeIgniter framework. I tried the exec and shell_exec command and it seems to not start the process. Please find the code below which I try to execute.
$phpPath = exec('which php');
$cmd = $phpPath.' '.dirname(__DIR__).'/API/notification/NotificationServer.php';
echo "<pre>".shell_exec($cmd)."</pre>";
When I try running the above in Terminal it executes fine. I need to automatically trigger this once the user has a session set.
The path/$cmd variable prints
when I print the variable $cmd i get the below output, and the below when given in terminal works fine.
/usr/bin/php /Users/lalithb/Desktop/Android/AndroidWS/API/notification/NotificationServer.php
the above command works fine in the Terminal. When i try to exec/shell_exec it, it is not working.
APACHE_ERROR LOGS ARE :
sh: line 1: 2437 Trace/BPT trap: 5 /usr/bin/php
sh: line 1: /Users/lalithb/Desktop/Android/AndroidWS/API/notification/NotificationServer.php: Permission denied
Can someone help me out in running this above code in CLI ?
I solved the problem, Guess there would be someone else like me trying to access the restricted folders. I found the solution here
http://ubuntuforums.org/showthread.php?t=1302259
exec('chmod +x'.dirname(__DIR__).'/API/notification/NotificationServer.php);
The above worked the magic.

Linux command called "file" returns "application/x-empty" only when executing through web

I'm trying to execute the command "file /directory/*" through the web, using Ajax that call a perl script.
When I'm running the script from the server I get the mime type correctly, but when i'm using the web that trigger the ajax, i'm getting "application/x-empty".
If i'm running the command from the server using "sudo -u apache perl_script.pl" - the result is correct.
Why from the Ajax I get a different response ?
Try without the asterisk but instead with a complete filename.

Resources