IIS appcmd called via Go app - Invalid XML input - iis

I have this command, which works when running in command line directly.
import "os/exec"
...
out, err := exec.Command("cmd", "/C", `%windir%\system32\inetsrv\appcmd list APP /site.name:"My website" /text:[path='/'].physicalPath`).Output()
When I run it via Go app, it throws exit status 3222072890 with this error message:
Failed to process input: Invalid XML input - please make sure that your XML is well-formed and follows the required format (HRESULT=c00cee3a).
I've already tried to change slashes, use various quotation marks, but still does not work.
I use IIS 8.5 on Windows Server 2012 R2.
It seems that command is corrupted before execution. Is there any way how to see the output command?

It seems to be a bug in golang library - related to a Golang Github issue #15566.
Issue is caused by quotation marks in /site.name argument ("My website") which are escaped, but should not be.
Solution for this time is this:
import "os/exec"
import "syscall"
...
cmd := exec.Command(`cmd`)
cmd.SysProcAttr = &syscall.SysProcAttr{
CmdLine: `/C %windir%\system32\inetsrv\appcmd list APP /site.name:"My website" /text:[path='/'].physicalPath`,
}
out, err := cmd.Output()
For more information see: http://www.josephspurrier.com/prevent-escaping-exec-command-arguments-in-go/ and exec with double quoted argument

I just deleted all carriage returns in xml
and removed Tag
.
And
appcmd add apppool /in < C:\Installs\AppPool.xml
worked for me.

Related

Linux:load error:No such file or directory

I am deploying a web server, and after I finish compiling.There are the executing documents;
01client.c client epoll_server.c server
Then I try to run server
./server
There is an error which I cant fix it. I have search ways for solving but still can't fix it.
load error: No such file or directory
Maybe some one can help me,please!
Thanks a lot!!!!
System utilities print the program generating the error at the beginning of the line followed by other useful information such as the name of the missing file, so this is probably an error from a user program. I can duplicate the error as follows:
errno = 2;
perror("load error");
which prints:
load error: No such file or directory
Look for the perror line in the server code. If it isn't clear what file it can't find, print the string from the failed command it is reporting.

Why is this twurl command (run on linux, by golang exec) not being authenticated?

I'm currently working on a Golang website (running on Ubuntu) that will update a twitter status. I used twurl customer key authentication on the system and I can successfully update the status if I type directly into the linux terminal. For example
ssh/putty into target system
type in terminal: twurl -d 'status=is this thing on' /1.1/statuses/update.json
twitter status successfully updated
When I try to do the same through Golang exec, twitter gives me an authentication error.
func UpdateMainStatus(status string) {
statusarg := `'` + "status=" + status + `'`
out, err := exec.Command("twurl", "-d", statusarg, "/1.1/statuses/update.json").Output()
}
I've tried a couple of different methods for formatting the statusarg. Printing the above statusarg to the console shows: 'status=Windows worked, Testing update on ubuntu.'
Twurl does seem to be run as out shows an error response from twitter, {"code":32,"message":"Could not authenticate you."}. I suspect it has to do with the setup of the command...??? Or maybe the interpretation of the single quotes in the status argument???
Don't include the single quotes:
statusarg := "status=" + status
In Golang, "twurl" is a string containing twurl. In particular, the string data does not include the double quotes. Those quotes are just Go syntax for strings.
In Bash, 'status=Foo' is a string containing status=Foo. In particular, the string data does not include the single quotes. Those are just Bash syntax for uninterpolated strings.

folder path with space giving error in subprocess.call

drivesToMap = ["R: \\\\server1\folder", "G: \\\\server1\folder withSpace"]
for eachDrive in drivesToMap:
call("net use " + eachDrive)
In python 3 on a windows 10 machine I am getting the following error for the code above :
System error 1232 has occurred.
The network location cannot be reached. For information about network troubleshooting, see Windows Help.
How do I resolve the space? When I type in the command from a doc cmd it works succussfully:
net use G: \server1\folder withSpace
You likely need to wrap the drive in an additional set of quotes, since net use is a command prompt command it is anticipating that the drive name (which has spaces) is actually multiple arguments instead of one.
For instance:
drivesToMap = ["'R: \\\\server1\folder'", "'G: \\\\server1\folder withSpace'"]

Scala.js - pass command line arguments from SBT run

When running the app using the sbt run while developing normal JVM app, I can pass command line arguments using run <args>. When I try the same with Scala.js, I get an error "No valid parser available". When trying runMain variant like runMain Main.main arg, the error is "Expected non-whitespace character", with arrow pointing just behind Main.main.
Is there some way how to pass arguments to the Scala.js / Node.js application when running it from SBT?
(I am using Scala.js 0.6.15).
No, there isn't, because JavaScript does not have a notion of command-line arguments. Node.js does, but only if started from the command-line, and that use case is not supported by the sbt plugin, I'm afraid.
Feel free to file a feature request. I'm not sure it can be accommodated, but we can look into it eventually.
One can define a custom task calling node.js, and parse arguments using SBT parsers. Add this into build.sbt:
import complete.DefaultParsers._
lazy val runa = inputKey[Unit]("Run app with arguments")
runa := {
(fastOptJS in Compile).value // build it first
val args: Seq[String] = spaceDelimited("<arg>").parsed
val npmRun = "node index.js" + args.map("\"" + _ + "\"").mkString(" "," ","")
npmRun.!
}
You also need to create a file index.js in your project root, containing something like this:
require("./target/scala-2.12/xxxx-jsdeps.js");
require("./target/scala-2.12/xxxx-fastopt.js");
In the intervening years, a library has emerged to address this:
https://ben.kirw.in/decline/

How to configure CGI on IIS 7?

I did this
http://reboltutorial.com/images/rebol-iis.png
as explained here but it was for IIS 6
http://rebolforum.com/index.cgi?f=printtopic&topicnumber=39&archiveflag=new
I also activated 32 bits for application pool as explained here
http://blogs.iis.net/wadeh/archive/2009/04/13/running-perl-on-iis-7.aspx
But when browsing to the test script it doesn't work, seems to take forever showing nothing, then in the end shows this message error:
502 - Web server received an invalid response while acting as a gateway or proxy server.
There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.
I used a dedicated server on windows 2008
Source code of the test script:
REBOL [Title: "Cgi Test in Rebol"]
print "HTTP/1.0 200 OK^/Content-type:text/html^/^/";
print []
print ["Date/time is:" now]
print []
Should I ask on serverfault rather as nobody seems to know here ?
Finally I got my answer, here are the steps:
Open Server Manager from Administrative Tools.
Add role "Web Server (IIS)"
Try http://localhost/ from your browser. You should see the IIS7 Welcome Page.
Copy core.exe to c:\ (or somewhere else), right click on core.exe and open Properties window, give Read & Execute access to IUSR_xxxx under Security tab. (If you've any problem, try to give Read & Execute for Everyone)
Open "Internet Information Services (IIS) Manager" from Administrator Tools.
Click on Default Web Sites, double click on Handler Mappings, click on Add Module Mapping from the right panel and type the followings:
Request Path: *.r
Module: c:\core.exe -cs %s %s
Name: Rebol
Select Yes when Add Script Map dialog box appears. It will add the c:\core.exe -cs "%s %s" as allowed under ISAPI and CGI Restrictions list.
Create a test.r file under wwwroot folder. My test.r file contains following script:
R E B O L [Title: "Server Time"]
print "content-type: text/html^/"
print [<HTML><BODY>]
print ["Date/time is:" now]
print [</pre></BODY></HTML>]
And type http://localhost/test.r on your browser.
If everything goes well then it should work.
If you are trying with View.exe then you may need to put --noinstall to command line, otherwise when View start with IUSR_xxx user account it will open desktop & installation window and it stays background (you can see it from Task Manager).
c:\view.exe -csi %s %s
You may also need to put double quotes around %s if your script is in a path with spaces. Use the following form:
c:\core.exe -cs "%s %s"
Instead of this:
c:\core.exe "-cs %s %s" (<-- this won't work!)
I hope this will help.
UPDATE: I've faced a problem on IIS6 (Windows 2003 Server), it gives 404 when I configure it as follow (it works on IIS7 as told above):
c:\core.exe -cs "%s %s"
But it runs as:
c:\core.exe" -cs "%s" %s
Here is the link for Perl installation.
http://www.howtogeek.com/50500/how-to-install-perl-on-iis-6-for-windows-server-2003/

Resources