I am trying to suppress the output window which pops up after executing a psql command in NSIS
ExecWait 'psql -U postgres -f "Path\To\File.sql" postgres'
I tried '>nul' after looking at this link. But that doesn't work.
To avoid the black DOS box, you can use nsExec::Exec instead of Execwait.
Using vanilla NSIS, you can also use ExecShellWait with SW_HIDE like so:
ExecShellWait "" "$INSTDIR\myservice.exe" "install" SW_HIDE
...although nsExec is clearly the way to go if you want to capture output.
Related
I'm trying to switch from vim/gvim to neovim on Linux. Up to now my standard workflow started with opening the cli, navigate to my project directory, and run gvim <filename> with the file I intend to start working with.
With neovim I can start it from the KDE menu to get a nice GUI. according to the menu settings, it simply runs nvim with an optional filename parameter. But I don't find the way to run nvim from the cli in a way, that it starts the GUI. Running nvim <filename> simply starts the cli UI.
Google gave me a lot of interesting information, but not, what I'm looking for.
There are different GUIs for neovim. Check which one do you actually use and start it from the command line. Navigate to the KDE menu for neovim GUI, right-click on it and select Edit application... Go to the Application tab and check the Command edit box. There you'll see the actual command which is run by KDE when you select the corresponding menu item. You can create your own shell script or alias which will run this command and use it on the command line.
UPDATE
Maybe some parameter or environment variable is passed to nvim so it changes its behavior. You can try to see what system call KDE actually performs to start the editor. For example, I'm using KDE plasma, so pidof plasmashell gives me the pid which I need. Then:
strace -f -v -e trace=execve -p `pidof plasmashell` &> plasma.trace
After that go to KDE menu and start neovim. Terminate the strace command with Ctrl-C and check the plasma.trace file for the execve system calls made to start the neovim process.
I have a script I am trying to run with grunt using the grunt-shell plugin. This script prompts for input using read -p "enter foo" bar. When I run it, I get a cursor that correctly takes my input, but I don't see "enter foo".
I tried modifying the grunt-shell config to dump err, stderr, and stdout to the console, but they all come out empty once the command completes. The man page for read says about the -p flag "The prompt is displayed only if input is coming from a terminal.", which seems like it may be my issue since node is calling the prompt, but the read command is executing in my terminal, and I am entering input in a terminal, so why wouldn't that work?
So, my question is, is there any way to prompt for user input from the grunt-shell plugin?
Also, as a P.S., yes i know it would be very easy to just echo the prompt and deal with the input being below it, but dammit it's the principle of the thing.
I redirected my code back to /dev/tty.
Ran it as bash -c run.sh </dev/tty
On Ubuntu precise
I am calling "dpkg -q --commit ./ patchsetname"
When I do this it decides to open an editor using the select editor binary.
I want to suppress that. Any thoughts?
I'd rather not have to interrupt the exec syscall with a shared library and filter for the editor query. There should be a cleaner way of doing this.
I just fixed this with the following:
EDITOR=/bin/true dpkg-source -q --commit . patchsetname
This will (obviously) use true instead of nano and at least on kubuntu this seems to work fine.
I have a file include some linux command and I want to run in on windows (DOS command).
The command is:
cat tmp/$id/index.html | sed -e 's/ID/$id/g' > a;mv a tmp/$id/index.html
What is the similar command in MS-DOS?
Thank you!
The problem is that natively there is no equivalent command to sed. You have two options from my point of view. Either create a vb script that does what you want (It will not take 1 line though - more like 10-15 I guess), or use something like GnuWin32 that gives you the option to run unix commands in windows terminal.
You could consider using powershell to do approximately the same thing. It supports cat and mv and you can get a sed like equivalent by using %{_ -replace "expression", "replace"}. Details here http://blogs.msdn.com/b/zainnab/archive/2007/07/09/grep-and-sed-with-powershell.aspx
Or consider using a linux like command prompt like bash which should be available through cygwin
I think this is impossible to do in "bare" command line (as you called DOS command), because cat and sed are separate utilities. If you want to port this script from Linux command shell to windows command line, I would advise you to download and install CygWin
DOS itself does not have support for that. You could try with a port of SED for DOS available here. If you can get Powershell, that's an option. Here's an example of using grep/sed with Powershell.
There are many options.
You can try to install cygwin or download and install Git and use Git-bash or add the bin directory to your PATH so you can run this command on your CMD prompt.
There is no such command(s) for MS-DOS.
I'm creating my first NSI script and I'm just wondering if I can execute a command-line command from NSIS or should I just execute a batch file? I don't really know where to begin and other similar topics have gone a little over my head.
I would recommend taking a look at the nsExec plugin. I just recently had a situation where I needed to ping a server from inside an NSIS script, and the following code worked perfectly for me.
nsExec::Exec '"C:\Windows\System32\PING.EXE" $URL'
The benefit of using nsExec is that it executes the command without making a dos box pop up on your screen. The return value is pushed onto the stack, and there are a couple different ways that you can access the output of the program as well (if any exists).
There isn't a whole lot of information about the plugin on the NSIS website that I could find, but the following link should get you started in the right direction:
http://nsis.sourceforge.net/Docs/nsExec/nsExec.txt
Edit:
I noticed you asked specifically about a COPY command which is an internal DOS command, meaning that you won't be able to execute it like I did with ping. I may be mistaken but you shouldn't need to use any outside programs to carry out basic commands like this. You should be able to replicate most of the internal commands using NSIS commands.
For Example to copy a file (or multiple files) use the NSIS command: CopyFiles
The NSIS Scripting Reference is your friend :) (So is ctrl+f)
Try using exec command http://nsis.sourceforge.net/Docs/Chapter4.html:
4.9.1.2 Exec
command
Execute the specified program and continue immediately. Note that the file specified must exist on the target system, not the compiling system. $OUTDIR is used for the working directory. The error flag is set if the process could not be launched. Note, if the command could have spaces, you should put it in quotes to delimit it from parameters. e.g.: Exec '"$INSTDIR\command.exe" parameters'. If you don't put it in quotes it will not work on Windows 9x with or without parameters.
Exec '"$INSTDIR\someprogram.exe"'
Exec '"$INSTDIR\someprogram.exe" some parameters'
We can launch a command-line command from NSIS, get the returned value and further develop the installation logic based on that.
Example: Let's say we need to get the installed clang compiler version. To get the version we have to launch:
clang --version
In NSIS we do this using ExecToStack:
nsExec::ExecToStack 'cmd /c "clang --version"'
Pop $0
Pop $0
;now we have the version in $0
Warning: Only the second Pop $0 gets the response that we want, in this case the clang version. The first Pop $0 grabs the exit code.