Cannot load a plain text file generated by a PHP - script using curl utility - unix

I am sitting on a Mac OS X system and I cannot get around a simple problem from the domain of working with the command line: using the command curl http://mureakuha.com/dl.php?type=1&id=1234 I get no data from a (obviously) PHP script generating plain text files.
I expect the solution to be a matter of passing right flags to curl, yet I have no clue where to start. Any help much appreciated.

Try curl 'http://mureakuha.com/dl.php?type=1&id=1234'. The problem here is the unquoted & symbol in url.

Related

cmd from R with wkhtmltopdf

I am trying to use wkhtmltopdf to turn website content into pdf and then read it into my R. So I write in my COMMAND PROMPT line to download as html front page of yahoo finance (just for fun). So i create "TemporaryFolder" on my C and write in cmd:
C:\Program Files\wkhtmltopdf\bin>wkhtmltopdf https://finance.yahoo.com/ "C:/TemporaryFolder/myhtml.pdf"
And it downloads yahoo finance website as pdf. Now I want to do the same thing but using R script. I know there is system function however I have very little experience with it (and with cmd to be honest).
So now i try use this command in my Rstudio so I can later create R script which downloads website as html and converts it to pdf.
URL="https://finance.yahoo.com/"
wkhtmltopdf_dir="C:/Program Files/wkhtmltopdf/bin"
save_as="C:/TemporaryFolder/myhtml.pdf"
x=paste0(wkhtmltopdf_dir,">","wkhtmltopdf"," ",URL," ",'\"',save_as,'\"')
system(x)
I also tried shell(x) but I got "permission denied".
But it does nothing... Could someone elaborate how system works and what should be added here?
BTW: can I harm my computer by using system? For example writing some "bad" command? This question might sound silly, but I am really to new to this.
What you're trying to paste as a command ("C:/Program Files/wkhtmltopdf/bin>wkhtmltopdf https://finance.yahoo.com/ \"C:/TemporaryFolder/myhtml.pdf\"") doesn't quite work. The first part ("C:/Program Files/wkhtmltopdf/bin>) is actually the prompt when you run it in commander. It's not a part of the command, but instead shows in which directory you are running that command.
If you replace wkhtmltopdf with C:/Program Files/wkhtmltopdf/bin/wkhtmltopdf.exe, it should work just fine:
URL="https://finance.yahoo.com/"
wkhtmltopdf_exe="C:/Program Files/wkhtmltopdf/bin/wkhtmltopdf.exe"
save_as="C:/TemporaryFolder/myhtml.pdf"
x=paste0(wkhtmltopdf_exe," ",URL," ",'\"',save_as,'\"')
system(x)
To answer your second question, a call to system() runs the command through CMD. So basically anything you could mess up through CMD.exe, you can mess up through system().
I figured out what was wrong. As i posted in comment, after using shell(x) instead of system(x) it returned 'C:/Program' is not recognized as an internal or external command, operable program or batch file.. So I reinstalled my wkhtmltopdf to folder which name contains no spaces. So wkhtmltopdf_exe is now:
wkhtmltopdf_exe="C:/Programs/wkhtmltopdf/bin/wkhtmltopdf.exe"
Rest of the code is the same. Followup here would be nice, is there any way to workaround spaces in folder names? Or should I always avoid spaces? Putting wkhtmltopdf path into quotation marks didnt help.
Thank for user JAD for fixing my first code

OS X Arduino 1.6.8 CLI MainClassNameRequired

Whenever I try to run any Arduino CLI commands, I am always getting a popup saying "MainClassNameRequired". What is going on and what do I need to do to be able to run arduino CLI commands?
I found the following JA.SO question and answer: https://ja.stackoverflow.com/q/20667.
My Japanese is terrible, and Google Translate didn't help too much, but the paths in the answer were correct and I was able to get the gist & get it working.
It turns out that, for whatever reason, the Arduino symbolic link created in /usr/local/bin, even though it is linked to the correct executable, doesn't actually pass the parameters through.
The Japanese answer suggested two solutions, both of which work. Firstly, remove the existing symlink from /usr/local/bin, then you can either:
Create a shell script wrapper to call the Arduino executable that will pass parameters through and then link create a symlink to that (or just make it executable and place it in /usr/local/bin):
#!/bin/bash
exec /Applications/Arduino.app/Contents/MacOS/Arduino "$#"
ln -s /usr/local/bin/arduino arduino.sh
Create an alias
alias arduino='/Applications/Arduino.app/Contents/MacOS/Arduino
Now when you execute arduino from your command prompt, your parameters are correctly passed to the program.

Scilab issue with exec command

I am using Scinote 5.4.0 with OSX 10.7.4. I am unable to execute script files from the console using the exec("path") command; when I do so, only the first line of the script file is read.
Example:
-->exec("plot1.sce")
-->x=[0:.1:10]'; //(the first line of my code)
If however I "execute with echo" from the editor Scinote, the script will run just fine.
Does anybody know what is going on? (The script files I am trying to run are in my present working directory).
Thanks!
Update: I just installed Scilab on an identical machine and the same thing is happening.
Update: Per Scilab's bugtracker, it appears to be caused by Scinote defaulting to cr eol on a mac. I don't really know what this means or how to fix it, but the adventure continues!
Update: I found the solution!:http://comments.gmane.org/gmane.comp.mathematics.scilab.user/6184
In the preferences, I changed the eol to Unix, and the default file encoding to iso-8859-1. I restarted and exec is now working!
The link is not easy to follow so here's the answer (pasted)
The problem is actually scinote's, not scilab's. I don't have a Lion
machine to check if I'm correct, but it seems scinote's file encoding
is no longer compatible in ML. I discovered that when I opened scinote
generated files with a different text editor (vi) the new lines
weren't encoded right for my machine. The other give-away was that
executing scripts written prior to upgrading worked fine.
Go to preferences and in the scinotes tab, switch default file
encoding to iso-8859-1. I also switched the end-of-line to Unix.

Download a file through a server script via curl

So I'm trying to download a file that works fine in the browser, but will simply not work using curl:
$ curl http://www.partner.viator.com/partner/admin/tools/links_feeds/downloadFeed.jspa?feed=Products&PUID=10869 -L --O full_viator_product_list.zip
I get:
[1] 10097
-L: command not found
What am I doing wrong?
(Just to prove I've done some homework, the issue here did not help.)
See the & in the url? that's where it goes wrong. On the Linux command line, this basically means 'run the command in the background, and continue to the next command, if any'.
If you put the entire url in quotes, it will work: curl 'http://www.partner.viator.com/partner/admin/tools/links_feeds/downloadFeed.jspa?feed=Products&PUID=10869' -L --O full_viator_product_list.zip
When using commands like this, make sure you always either quote or escape them. If you don't do this, nastier things than this problem can happen.

Hello World Java Servlet doesn't work

I'm using amazon's EC2, and I'm trying to run this tutorial
http://helloworldprograms.blogspot.com/2010/08/servlet-hello-world.html
When applying the command:
javac -cp .........\lib\servlet-api.jar test\HelloServlet.java
(with the appropriate path of course) i'm getting the following errors:
Also, we are using apache-tomcat-6.0.33, but when entering http://localhost:8080/ the version of apache is 6.0.32.
Can someone help me with this?
Thanx
The compiler didn't find you servlet-api.jar.
Try to use a absolute path to this file,
maybe you can use a simple path like /tmp/servlet-api.jar.
Your tomcat is in user's home?
Why you are using '.' on the path's start?

Resources