More than 1 cgi in cgi-bin

I wanted to have more than 1 cgi app in /cgi-bin/
In another thread someone said to use /cgi-bin/app1/app1.cgi and /cgi-bin/app2/app2.cgi (at first I missed the appX subdirectory)

After some tests and building webtest1.cgi and webtest2.cgi, I see both are the same perl script looking for config.cfg to find the name of the app and other settings. If I install webtest1.cgi in /cgi-bin/ then webtest2.cgi, when I try to go to /cgi-bin/webtest1.cgi then webtest2 is executed (because config.cfg is pointing to appname webtest2)

Solution: rename config.cfg to appname.cfg and edit appname.cgi changing the line:

	return $dir . "/config.cfg";


	return $dir . "/appname.cfg";

Running fine so far:

Edit: found this <>
Edit2: could it be possible to create a script that run as Build Step to move config.cfg to appname.cfg and change appname.cgi line above? I’ll search for more information.

I’m thinking about the Build Steps. What I will try to do is:

  • have 2 parts of the cgi file and copy those files, like t1.txt just before config.cfg and t3.txt from .cfg to the end of the cgi
  • execute a few shell commands:

mv config.cfg appname.cfg echo -n 'appname' > t2.txt cat t1.txt t2.txt t3.txt > appname.cgi

At this point I don’t know if possible, from what I read up until now I think it is.

It was not that hard:

  • created Build Step - Copy Files and put t1.txt and t3.txt there
  • created Build Step - Script with this code:

Dim result As String result = DoShellCommand("cd " + CurrentBuildLocation + " && echo -n '" + CurrentBuildAppName + "' > t2.txt && cat t1.txt t2.txt t3.txt > " + CurrentBuildAppName + ".cgi && mv config.cfg " + CurrentBuildAppName + ".cfg && rm t1.txt && rm t2.txt && rm t3.txt")