cronjob not working, but working in browser - apache

So I have this weird behaviour:
A customers runs an oxid-shop. He bought a module and in its documentation, it stated:
Add 3 cronjobs: < url >
So, nothing too special so far. I tried it in the browser and everything worked fine. My output was:
Convert complete! 0 articles. File: google.xml
So the Script seems to work. Then I tried to combine it with a cronjob.
*/02 * * * * curl http://www.example.org/index.php?cl=param1&fnc=param2&rto=param3
as you can tell, a complete valid url (no special chars or something like this in the vars)
However, the output is the following:
Warning: Smarty error: unable to read resource: "" in /usr/www/users/.../www2/core/smarty/Smarty.class.php on line 1094
I also tried it with lynx -dump URL. Same output. I can't modify the script, since it is encrypted.
Any idea what I could try? Might the be due to the params?
Tried it on 2 different servers with the same outcome.

The problem could in deed be that there are parameters in your URL.
When using [] or {} sequences when invoked from a command line prompt,
you probably have to put the full URL within double quotes to avoid
the shell from interfering with it. This also goes for other
characters treated special, like for example '&', '?' and '*'.
Source: https://curl.haxx.se/docs/manpage.html
So you should try to enclose your URL with double quotes.

Related

Postman Path Variables without slashs

I have a basic GET request with a CustomerName path variable that I am trying to access in Postman like so:
https://my-domain.com/../{{version}}/{{tenant}}/{{company}}/AR/ARCustomers(":CustomerName")
For some reason the : doesn't get recognized as a PATH variable without a / or \ in front of it like so /:. Additionally the path variable will be seen as CustomerName") unless I escape the ". If I was to enter this the way I think it expects then I would end up with ARCustomers("/:CustomerName/") but unfortunately when I do that it gets translated in the curl like so ARCustomers("/TEST/")' (adding the unnecessary /s).
How do I set a path variable without the forward slashes, is this not possible?
Additionally in this example I'm using " around my path variable but I actually need it to be ', unfortunately that two is causing issues with forward slashes in my cURL
if your url is like :
https://my-domain.com/AR/ARCustomers("/:CustomerName/")
Then in pre-request script use:
path = pm.request.toJSON().url.variable.find((a)=>a.key==="CustomerName").value
console.log(pm.request.url.toString())
pm.request.url=pm.request.url.toString().replace(`/${path}/`,path)
console.log(pm.request.url.toString())
Postman properties are exposed through pm object and you can modify most properties except body from prerequest script.
Here we are replacing /content/ with content

Run a binary CGI file on the command line with GET params

How can I run a binary cgi file on the command line and provide GET parameters to it?
I understand this task may be straightforward for perl or php files, but I've got a binary cgi file and no documentation for it. I'd like to run it without a web server so that I can evaluate certain problems on some co-workers' machines.
I've tried the following, but to no avail:
QUERY_STRING="foo=bar" ./myfile.cgi
foo=bar ./myfile.cgi
./myfile.cgi foo=bar
./myfile.cgi <<< "foo=bar"
In each case, the script outputs Error in form found<br>Missing foo<br><b></b><br>. (When executed through apache on our server, it returns no error message, only the intended results.)
Specifying the environment variable REQUEST_METHOD=GET in addition to QUERY_STRING=... makes the difference.
Among the tokens output by strings myfile.cgi, there were a number of cgi-related variables which the web server might be expected to set, such as REMOTE_ADDR, SERVER_SOFTWARE, and SERVER_PROTOCOL, but the two aforementioned variables proved enough to get this executable to produce a non-error output.
(For a POST, I've read that the body/params are read from stdin, but I haven't substantiated that personally.)

Getting names of all private repos through GitHub API

I'm trying to get a list of all names in a repo that I have access to. I tried running:
curl -u username:pw -X GET https://api.github.com/orgs/org_name/repos?per_page=100 >> list.txt
but I get the error: zsh: no matches found: https://api.github.com/org/org_name/repos?per_page=100
All I want is a list of the repos... no other information. Can't seem to figure it out. I'm new to programming and started using API like.. 1 hour ago? Any advice would be helpful.
Your shell (zsh) is interpreting the URL as a path and complaining because it doesn't match any files. You can solve this by placing quotes around it. In this case, either single or double quotes will work.

How to set and get variables when working in cmd

I am working in cmd to send HTTP GET and POST requests with cURL.
There are many times where I am sending requests to the same pages and typing them out every time is a huge pain.
I'm trying to figure out how to use set= so that I can save these URLs for each time I want to use them.
I've tried
C:\>set page = "http://www.mywebpage.com/api/user/friends"
C:\>page
'page' is not recognized as an internal or external command,
operable program or batch file.
C:\>echo %page%
%page%
but it won't return the page name.
How can I accomplish what I need?
C:\Windows\system32>set page="http://www.mywebpage.com/api/user/friends"
C:\Windows\system32>echo %page%
"http://www.mywebpage.com/api/user/friends"
C:\Windows\system32>set page=http://www.mywebpage.com/api/user/friends
C:\Windows\system32>echo %page%
http://www.mywebpage.com/api/user/friends
Don't use spaces around =. Select version with or without " according to your needs. Variable value may contain spaces inside:
C:\Windows\system32>set page=http://www.mywebpage.com/api/user/my friends
C:\Windows\system32>echo %page%
http://www.mywebpage.com/api/user/my friends
You are setting the value "http://www.mywebpage.com/api/user/friends" inside the variable "page " (notice the space) since you have a space before the =.
So you can either retrieve the value by using %page % or by using set page="http://..." without a space between page and the equals sign

WebHCat & Pig - how to pass a parameter file to the job?

I am using HCatalog's WebHCat API to run Pig jobs, such as documented here:
https://cwiki.apache.org/confluence/display/Hive/WebHCat+Reference+Pig
I have no problem running a simple job but I would like to attach a parameters file to the job, such as one can do using pig command line's parameter: --param_file .
I assume this is possible through arg request's parameter, so I tried multiple things, such as passing:
'arg': '-param_file /path/to/param.file'
or:
'arg': {'param_file': '/path/to/param.file'}
None seems to work, and error stacks don't say much.
I would love to know if this is possible, and if so, how to correctly achieve this.
Many thanks
Correct usage:
'arg': ['-param_file', '/path/to/param.file']
Explanation:
By passing the value in arg,
'arg': {'-param_file': '/path/to/param.file'}
webhcat generates "-param_file" for the command prompt.
Pig throws the following error
ERROR org.apache.pig.Main - ERROR 2999: Unexpected internal error. Can not create a Path from a null string
Using a comma instead of the colon operator passes the path to file as a second argument.
webhcat will generate "-param_file" "/path/to/param.file"
P.S: I am using Requests library on python to make the REST calls