I am very new to Clojure and am following Clojure for the Brave and True. One of the steps is to create ~/.lein/profiles.clj . I cannot find how I am supposed to do this so any help would be much appreciated.
Thanks in advance
From your question, I take it that you are a) on a Linux system and b) do not yet know your way around Linux. Is that correct?
If so, there are a few things, you should know:
Filenames beginning with a dot are hidden. You can not see them in normal file listings. All graphical filemanagers have a switch somewhere to show hidden files. If you are typing in a terminal, you can use the -a option of the command ls to show them. Compare the output of ls ~ and ls -a ~on the command line. You can usually get a command line if you start a "terminal" or "console" from menu.
You can create directories on the command line with mkdir. In this case you would call it like this: mkdir ~/.lein on the command line.
You can then use one of the many, many text editors to create and edit the profiles.clj file. For example, on the command line call gedit ~/.lein/profiles.clj to open a graphical editor. It should be installed on most systems. If you do not have a graphical user-interface, you could try the editor nano instead of gedit
If you are on a Windows box, all these instructions make no sense. In that case, I cannot help you much as I have never run Clojure on Windows.
If you are already an experienced Linux user and I just misread your question, I beg your pardon for stating the obvious.
Related
I do not see native GDB commands can do this: check if a gdb script file exists, if so, source the file.
Maybe I need to resort to python, but still want to ask here.
The use case is, I am working on several different computing environments, each one has some different GDB setup. I like to add the above to ~/.gdbinit so that even in each environment I have a different GDB script, it is automatically sourced in my ~/.gdbinit.
There's no built-in way to do this. It can be done via scripting in a couple of different ways.
The classic way is to use shell to test the file existence and have it write out a file that then decides what to do. Something like:
(gdb) shell if test -f blah; then echo source blah; fi > /tmp/F
(gdb) source /tmp/F
This is pretty ugly, but it would work.
Alternatively you can write a Python command to do this quite easily. Or you can dig up the Python ignore-errors command, and just use ignore-errors source whatever.
I have a program I've written in c++ which outputs some simulation results to a .csv excel file.
According to some instructions I need to create a simple bash script that would run the .cpp file given the command "$ run_program" ($ is not a part of the command).
I've looked on Stackoverflow and other sites however I have not found a concrete answer to help me. I would also greatly appreciate it if those who answer can take some time to explain what the parameters mean.
Thank you.
How I should make a bash script to run a C++ program?
This is one of the links I've looked at, however I could not make heads or tails out of this.
i dont know the command you are using to compile your c++ program but this might help you.
Create a file with ".sh" extension and open it with your favorite text editor.
Paste this code (change compiling line with line you are using to compile your progam)
#!/bin/bash
#Run this in terminal
#+ Command to compile c++ program. here i used common one
g++ filename.cpp -o anyname
exit 0
Now you need to run this script, To do this open a terminal
chmod u+x scriptname.sh
Then run the script by ./scriptname.sh
Hopefully this will compile your program.
It sounds like a Makefile is what you are looking for here. Definitely worth getting a handle on if you deal with programming.
I want to create one unix command, which will unzip the folder.
so, I am searching for the code, but I am not aware that how should I use such code to make Unix command?
I have gone through various questions & answers but I don't get any perfect information.
So, can any one please suggest me any code (in C++ or C or any language to make exe) and to use it as a Unix command.
NOTE: I know command like 'unzip' is available in 'Mks toolkit' type of software but we can not use it, so I want to make command which can run through 'command prompt'
If you want to add a command, you only need to create your executable and put its link in the /usr/bin folder.
Just compile your code and set a link to it's executable like this:
ln -s /path/to/your_executable /usr/bin/command_name
If there exists a command that you need to modify, you should set an alias to it. For example, you want ls -1 to run whenever ls is used, then you only need to use the command:
alias ls=ls -1
or put the same command in the .bashrc file in your home directory.
I want to use the Windows CMD tree command in my C++ console application. My code:
system("cd c:/");
system("tree");
The problem is that the command tree will execute on the folder path where the program is running and not on C://. Is there a way to fix this?
Why not :
system("tree c:\");
?
TREE [drive:][path] [/F] [/A]
/F Display the names of the files in each folder.
/A Use ASCII instead of extended characters.
You can use SetCurrentDirectory from windows.h. This page has a demonstration:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa363806%28v=vs.85%29.aspx
Your problem is that the system("cd c:/") is executed in a shell, and then the shell exits. [It's also wrong, because you use the wrong kind of slash, it should be "cd c:\\" - the double backslash is needed to make one backslash in the output, assuming we're talking about a Windows system].
There are a couple of different ways to do this:
Use chdir() (or SetCurrentDirectory) function call to change the main processes current working directory, and then call system("..."). This is the simplest solution.
Generate all your commands into a batch file, then pass the batch file to system.
Open a command shell with something like _popen() and pass commands into the pipe that you get from that.
Manually create pipes and connect them to the standard in and standard out of a process that runs the command prompt.
Just for programs in Windows, include "windows.h", then
SetCurrentDirectory("c:/");
system("pwd");
While I'm still curious why would you want to do this, you can try to run all commands in one system() call:
system("cd c: && c: && tree");
Second c: is needed to change drive letter, in case if you're not currently on drive c: (because cd doesn't do it).
I have a C shell script that calls two
C programs - one after the another
with some file handling before,
in-between and afterwards.
Now, as such I have three different files - one C shell script and 2 .c files.
I need to give this script to other users. The problem is that I have to distribute three files - which the users must keep in the same folder and then execute the script.
Is there some better way to do this?
[I know I can make one C code file out of those two... but I will still be left with a shell script and a C code. Actually, the two C codes do entirely different things... so I want them to be separate]
Sounds like you're worried that your users aren't savy enough to figure out how to resolve issues like command not found errors and the like. If absolutely MUST hide "complexity" of a collection of files you could have your script create the other files. In most other circumstances I would suggest that this approach is only going to increase your support workload since semi-experienced users are less likely to know how to troubleshoot the process.
If you choose to rely on the presence of a compiler on the system that you are running on you can store the C code as a collection of cat $STRING >> file.c commands to to create your two C files, which you then compile and use.
If you would want to use pre-compiled programsn instead then the same basic process can be used except instead use xxd to both generate the strings in your script and reverse the conversion process to give you working binaries. Note: Remember to chmod the binary so that it is executable.
use shar command to create self-extracting archive.
or better yet use unzipsfx with AUTORUN option.
This provides users with ONE file, and only ONE command to execute (as opposed to one for untarring and one for execution).
NOTE: The unzip command to run should use "-n" option, that way only the first run would extract the files and the subsequent would skip the extraction.
Use a zip or tar file? And you do realize that .c files aren't executable, you need to compile & link them first?
You can include the c code inside the shell script as a here document:
#!/bin/bash
cat > code.c << EOF
line #1
line #2
...
EOF
# compile
# execute
If you want to get fancy, you can test for the existence of the executable and skip compiling them if they exists.
If you are doing much shell programming, the rest of the Advanced Bash-Scripting Guide is worth looking at as well.