In development i need to test console utility with server environment variables. Is there a way pass the environment variables and compile utility as if it were running on a server?
Something like a crystal prog.cr -- PROG_ENV=production?
You just set environment variables in your shell like for any other program and they will be available in the Crystal compiler. For example PROG_ENV=production crystal prog.cr
Related
I was going through this appdynamics document page for the installation of C/C++ SDK.
C/C++ SDK installation on Linux
But since, i am doing this for the first time, i am not sure what is meant in the 3rd point.
I think i have to set the location in my LD_LIBRARY_PATH env variable and then invoke them by typing
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/appdynamics-cpp-sdk/lib
Can somebody explain, what needs to be done?
Yes - you need to set "/opt/appdynamics-cpp-sdk/lib" in your "LD_LIBRARY_PATH" environment variable to use the SDK as you have posted.
Generally this is put in a script used to build your application which you are wanting to instrument.
I have a cross platform unit testing framework that I use for C++. In order to build and run the tests in XCode 6.1 I need to run a python script as part of a prebuild script.
Since I use the same unit testing framework for multiple projects I figured it'd be great to use environment variables in my ~/.bash_profile to point to the resources necessary for the python script. But it seems that XCode 6.1 doesn't load the bash_profile before running the script in the build process. Are there alternatives to using the bash_profile? Maybe I could add my environment variables to the XCode environment variables list? But this seems to be changing with each update to OSX. I can't seem to figure out where I can add environment variables for XCode 6.1.
You can run a shell script by adding a build phase to your target. The instructions are also here.
Select the project file
Select "Build Phases" at the top
Select Editor > Add Build Phase > Add Run Script Build Phase
Add your script in the box provided
in your case you can do:
source ~/.bash_profile
python [your_script]
You can rearrange the order of your build phases by dragging them into the order you want.
NOTE: The environment variables defined in ~/.bash_profile will not be there when you run your program (at least in my experience). To add environment variables to the run command:
Select Product > Scheme > Edit Scheme...
Select Run on the side bar
Select the Arguments tab
Put any Environment variables needed by your program in the proper section
I noticed that there are a couple of gdb specific environment variables introduced into the stack during debugging. Is there any way I could unset those environment variables alone?
I noticed that there are a couple of gdb specific environment variables introduced into the stack during debugging.
You must be using some kind of IDE, or a wrapper script, that does this. GDB itself doesn't modify environment, unless you ask it to with e.g. set env command.
I develop a Win32 C++ cgi app for windows and linux and start from scratch.
I use CgiCC as lib and Visual Studio 2010 as IDE.
How can I debug that? When I instanziate my cgicc class the program holds and waits for CGI input I guess.
How can I set up an environment for my CGI input?
I set some environment variables like QUERY_STRING.
But I have no idea how to provide the values my cgi app would get while running on a webserver.
EDIT:
I am almost there.
I captured the traffic while browsing and wrote that content to a file.
Then I redirected stdin to that file: "< input.txt" as debug command line arguments in visual studio.
I set some environment variables under windows like CONTENT_LENGTH and CONTENT_TYPE.
after that I can read some content from my input like this:
cgicc::Cgicc cgi;
string u = cgi("user");
but i get an exception (reading from unallocated memory and exceptions like that) while doing this:
vector<FormFile, allocator<FormFile>> files = cgi.getFiles();
somehow not everthing if loaded correctly.
CGI apps receive their input via environment variables and standard input, so you can easily replicate the environment that a web server sets up for the CGI task.
As far as environment variables, here is a list of the environment variables that are part of the CGI protocol. I recommend that you set all of them, either by hand or better yet, by capturing the environment given to a working cgi app by a production web server. Since environment variables are inherited by child processes, if you set these up in your environment inside a Windows command prompt and then invoke the Visual Studio IDE from that same window then these variables will be available when your CGI application starts inside the debugger and also when you run it without debugging.
Getting a standard input replacement can be a bit more complex in your case, since you are working with a file upload form. This site contains a template that should get you started with the multipart/form-data format. The official document for file uploads via forms is RFC 1867.
I hope this helps.
Solved it by myself:
Build cgicc with the same visual studio version that I compile my project with.
Build cgicc as a static library instead of a dynamic library.
Setting the preprocessor define CGICC_EXPORTS in my project which activated __declspec(dllexport).
Then it worked!
I am new to cgi and have an cgi C++ application to debug.
How can I set up the environment on my developer PC in order to debug in visual studio?
My app supports GET and POST method but I have no idea what to do to make it start up correctly.
The app is started through a link with some arguments like:
myApp.exe?mode=create&name=jack...
Any suggestions?
Thanks
juergen
If your parameters are usually sent as part of the URL, then they should be found in the QUERY_STRING environment variable. You normally get this by calling get_env("QUERY_STRING").
Before running, try setting the environment variable QUERY_STRING to contain mode=create&name=jack