Codeigniter 3 Cli not working - codeigniter

I am currently working with codeigniter3 and I have a problem with calling a function. To execute function in Cli, I used the command in terminal: "php index.php tools(controller) message(function in controller)". However, it does not access function and only prints index.php contents.
I have set uri_protocol in config file as 'AUTO'. How do I access function in Cli? Am I using wrong command?

Related

Unable to Pass option using getopts to oozie shell Action

I created a script in shell and passing the arguments using getopts methods in my script like this:
sh my_code.sh -F"file_name"
where my_code.sh is my unix script name and file_name is the file I am passing to my script using getopts.
This is working fine when I am invoking my script from the command line.
I want to invoke the same script by using oozie, but I am not sure how can I do it.
I tried passing the argument to the "exec" as well as "file" tag in the xml
When I am trying passing argument in exec tag, it was giving "JavaNullPoint" Expection
exec TAG
<exec>my_code.sh -F file_name</exec>
file TAG
<file>$/user/oozie/my_code.sh#$my_code.sh -F file_name</file>
When I am trying passing argument in File Tag, I was getting error, "No such File or directory". It was searching the file_name in /yarn/hadoop directory.
Can anyone please suggest how can I achieve this by using oozie?
You need to create a lib/ folder as part of your workflow where Oozie will upload the script as part of its process. This directory should also be uploaded to the oozie.wf.application.path location.
The reason this is required is that Oozie will run on any random YARN node, and pretend that you had a hundred node cluster, and you would otherwise have to ensure that every single server had /user/oozie/my_code.sh file available (which of course is hard to track). When this file can be placed on HDFS, every node can download it locally.
So if you put the script in the lib directory next to the workflow xml that you submit, then you can reference the script by name directly rather than using the # syntax
Then, you'll want to use the argument xml tags for the opts
https://oozie.apache.org/docs/4.3.1/DG_ShellActionExtension.html
I have created lib/ folder and uploaded it to oozie.wf.application.path location.
I am able to pass files to my shell action.

Calling a script within a script that was run via nohup

I have a script, which when I run to screen, works perfectly.
The directory structure is as follows:
/home/username/processing/ScriptRunning
/home/username/processing/functions/include_me
In the script, it opens another script, which contains a function by simply doing this:
#!/bin/bash
#This is ScriptRunning script
. functions/include_me
Now when I call the script using the following nohup command:
nohup /home/username/processing/ScriptRunning
this is the output:
/home/username/processing/ScriptRunning: line 3: /home/username/functions/include_me: No such file or directory
It seems to be missing out the processing directory
I've altered the line within the ScriptRunning to have a full path, both hardcoded to /home/username/processing and also having this as a variable created by calling $(pwd), but the error is the same.
Am I really missing something so stupid?
This isn't a nohup issue. You are including a source file using a relative file name. Try:
. $(dirname ${BASH_SOURCE})/functions/include_me
to include a source file located relative to ${BASH_SOURCE}

mysqldump: command not found XAMPP

I'm trying to use a script in grunt and node to dump a database.
When I run It return me this error:
/bin/sh: mysqldump: command not found
I have already contacted the creator of the script and we have understand that the problem is the configuration of my localhost.
I'm using XAMPP 1.8.2-3 in OSX
How can I use correctly mysqldump
Thanks
Try:
export PATH=$PATH:/Applications/XAMPP/bin
Then run your script.
So you don't have to do this in the future, check your .profile file in your home directory. There should be a line that starts with export PATH, something like (only an example):
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
Just add your XAMPP path to it:
export PATH=/opt/local/bin:/opt/local/sbin:/Applications/XAMPP/bin:$PATH
The different directories are separated by colons only, don't add any whitespace.

Ruby run shell command not working (for facebook app)

I am trying to run a system call which will post an activity to a user on facebook.
When I run this on the command line, everything works fine but on my RoR controller, I don't get any result. I have all the permissions required to post an activity for a user and I've already tried using system(), backticks(`), exec() and %x but still no luck.
Any idea on this? here's my code:
post = "curl -F 'access_token=#{session[:access_token]}' -F 'achievement=https://example.com/main/fbobject' 'https://graph.facebook.com/me/app_fb:send'"
system(post)
It's working fine now. For references, here's the solution.
On the server settings under directives,
I have:
SetEnv PATH /usr/local/bin
SetEnv LD_LIBRARY_PATH /usr/local/lib
and added:
SetEnv PATH /usr/local/bin:/usr/bin/
SetEnv LD_LIBRARY_PATH /usr/local/lib:/usr/bin/lib
I've included :/usr/bin/ and :/usr/bin/lib since curl command is located there.

Cakephp Shell Cronjob Controller Action Media Temple Server

I'm trying to create a cron job that will send a weekly newsletter. I tried creating a shell task following what Cakephp manual says. Then I go to the Media Temple Cron jobs and type in the following:
php /home/#####/domains/domain.com/html/cake/console/cake -app /home//#####//domains/domain.com/html/vendors/shells newsletter
I created the shell task on vendors/shell folder and named it newsletter.php and here's the code for it:
class NewsletterShell extends Shell {
function main() {
$this->sendEmailTo("Newsletter","subject","email#gmail.com");
}
}
The sendEmailTo is a controller function I have in my appController so all my controller have access to it.
My problem is every time the Cron Job runs I get this message:
Could not open input file: /home/#####/domains/domain.com/html/cake/console/cake
I even gave all the console files (cake.php , cake.bat etc) 0777 read write properties as well as for the vendors/shell/newsletter.php
The ##### are the site number that media temple gives you but I'm not really sure I have it correct. They show an example of a cron job like this: /home/50838/data/script-name.sh
So my questions are:
Is my cake shell task correct and is the way I'm running it as a cron job accurate?
Also does anyone know where to confirm my media temple site number so I can write that off as a possible error.
Thanks in advance,
Fabian
You can try to var_dump(ROOT) or any one of the other Core Definition Constants to find your directory. Just put it in a controller method somewhere, but make sure to remove it again. Or, if you have SSH access, do pwd on the command line.
Other than that, when invoking the cake console task, the -app parameter is supposed to point to the app directory, not the shells directory.
Try to use this script to run your shell as cron job, there may be some missing shell vars.
ls -l /home/#####/domains/domain.com/html/cake/console/cake
says what? does the cron job run as user #####? if not, the problem is probably permissions on /home/#####/, check them with
ls -ld /home/#####/
Have you given the "cake" file in "cake/console" directory executable permissions as well as cake.php and cake.bat?
The cron command should be:
php /home/#####/domains/domain.com/html/cake/console/cake newsletter -app /home/#####/domains/domain.com/html/app

Resources