I wrote a script to remote execute test.cmd file by PsExec.exe.
PsExec.exe \\IP -u administrator -p password "C:\\Users\Administrator\Desktop\test.cmd"
Although I can run the script successfully, I cannot press any key to continue the process when it runs into command pause.
Press any key to continue . . . aaaaaa
The only way to keep going is press Enter.
Besides, if there are many lines of Pause or set /p which waits users to input, once user press Enter, it will affect couple lines of Pause or set /p. It really confuses me.
Best is that you use different logic in accordance with your limitations.
Try exchanging the Pause with a different suitable solution.
Other suggestion would be that you share your code, inputs and expectations (output is already given - the script doesn’t continue). Then someone can review the code and suggest for further steps.
Alternatively, it is also possible that you can fix it by using Console.ReadKey()
Related
Mplayer provides shortcuts to change the track and play/pause the music but they only work if the mplayer window has the focus.
Is it possible, for example, to change the track currently played in mplayer with a command line? In that case, I could assign this command to a shortcut and use it even if mplayer does not have the focus.
All I found on google was how to use mplayer to play files or which shortcuts to change track when the window has the focus.
I am actually in the middle of trying to do this exact thing! I am going to share what I have discovered so far in case it helps anyone.
I have not been able to find a way to play/pause tracks. However, I have been able to change tracks, at least in terms of going to the next track.
I have found 2 ways so far: Using /proc/$pid/fd/0 and Named Pipes (FIFOs). Explaining FIFOs is a little harder (I just recently learned of them) so I will do that last.
Modifying STDIN via /proc/$pid/fd/0
We can communicate with a process in a different terminal session by redirecting input to the process' file definitions directory at /proc/$pid/fd/ where $pid is the process' PID.
Firstly, find the process ID using pidof. Make sure mplayer is actually running!
$ pidof mplayer
This will output the PID of mplayer. Using this $PID, we can input what we want to STDIN for mplayer by redirecting it to /proc/$PID/fd/0. (Note, 0 refers to STDIN, 1 to STDOUT, etc.). An example:
$ echo "p" > /proc/$PID/fd/0
This has the effect of changing the tracks for mplayer.
However, even though I used p in my example, I have found that you can echo anything (including nothing) and it will still accomplish the same goal of changing the track no matter what you input.
Named Pipes
Also called FIFOs, named pipes, just like regular pipes (|), redirect output to other processes. The main difference is that these are part of the filesystem and can be used to communicate between different terminal sessions.
To start off, create a new named pipe anywhere in your filesystem. I chose /tmp/.
$ mkfifo /tmp/mp3control.pipe
Then start mplayer redirecting its STDIN to the named pipe.
$ mplayer -playlist brutal_tunez.txt < /tmp/mp3control.pipe
It will look like the process hangs and that's because it is expecting the other side to input something.
Now open up a new terminal and input stuff into the pipe.
$ echo "p" > /tmp/mp3control.pipe
You will hear music start to play from mplayer. Again, just like before, any further inputs to the pipe will just change tracks.
I believe this has something to do with the way mplayer handles STDIN and is not the same thing as entering p to play or pause music.
I will continue looking into this but I would love to hear from someone if I made a mistake somewhere. All in all, this might end up being something where the amount of time spent is not worth it, to be honest. (But we still must!)
I'm very very new to programming/coding.
And I have a very specific question, which I didn't find any answers to.
This command below executes perfectly fine if the command is valid.
If I enter an invalid command, an error occurs and the cmd exits.
enter image description here
But how do I make it, if an error happens, the program starts from the beginning rather than the cmd window closes?
So, in short, I want "SIGNAL start" to happen if an error occurs.
I hope you understand, thank you very much.
other:
SAY "Enter your own command:"
PULL command
command
IF command=ERROR THEN DO
SIGNAL start
It would be helpful if you published all of your code but it seems that what you really need to do is code a loop.
/* REXX */
do forever
say "Enter a command"
pull command
"where" word(command,1)
if rc <> 0 then iterate
command
end
Ok I'm having trouble and google isn't helping, so I thought I'd come to you geniuses. I'm using Powershell and posh-git, and it keeps doing something that I'm sure I can exit out of with a magic command, I just don't know it yet.
Basically, when I run git diff (or something else with a long result), it will only give me a screen's worth of information, and end the screen with a colon
:
And if I keep pressing Enter it will add more to the screen til it is done showing everything for that command, and shows
<END>
But now what? How do I get out of this and back to calling commands? Enter, Esc and the other things I thought to try are not helping. I'm sure this must be a simple thing, but I don't know how to explain to Google what I want.
Anyone know?
if you do a git config -l you may see some relevant entries like:
core.pager='less'
pager.diff=false
pager.log=true
You can enable or disable the pager for different commands, or set a different pager. https://www.kernel.org/pub/software/scm/git/docs/git-config.html has the details, check out the core.pager section and pager.<cmd> sections for specifics.
If you're using 'less' as your pager, hit 'h' at that : prompt to get lots of details about what you can do there, and as pointed out by others, q, Q, or ZZ will get you back to the command line.
You can terminate the current command using CTRL+C. Is that what you're asking?
I'm attempting to use epa mode and org mode in emacs as laid out by this article.
I'm attached to the computer using a screen session and ssh. I therefore needed to change /usr/bin/pinentry to point to /usr/bin/pinentry-curses as /usr/bin/pinentry-gtk-2.
I have
pinentry-program /usr/bin/pinentry-curses
as the last line in my .gnupg/gpg.conf. When I attempt to save the file I am presented with this menu:
Select recipients for encryption.
If no one is selected, symmetric encryption will be performed.
- `m' to mark a key on the line
- `u' to unmark a key on the line
[Cancel][OK]
I select 'ok' but only get
Opening output file: Encrypt failed, Exit
I get no prompt for my passphrase and no other output is given. It doesn't promp for a passphrase. It doesn't even list my gpg 'user' as foo#bar.com.
However when that line isn't present in the .gnupg/gpg.conf file I do see my gpg 'user' in the 'Select recipients for encryption' dialog. However, the cpu is pegged with the message stating:
Encrypting /home/user/test.gpg...
(I'm assuming as it is trying to spawn the gtk window and running in circles)
I'm a little confused as to why I needed to link /usr/bin/pinentry to /usr/bin/pinentry-curses and have the line in my gpg.conf file.
Before when /usr/bin/pinentry was linked to /usr/bin/pinentry-gtk-2, if I was on the local machine I'd get the 'Select recipients encryption' prompt with my gpg user listed. I'd get a dialog to input my passphrase and it all worked. I'd get
Encrypting /home/user/test.gpg...
and it would all succeed.
I'm running GNU Emacs 24.2.1 on an Arch system that is up to date as of this morning.
I'm curious what I'm doing wrong.
I've checked out the articles on pinentry and gpg on the arch wiki and they haven't helped to solve the problem.
Thanks in advance.
UPDATE: 26-10-2012 An update this morning to package cryptsetup seems to have influenced behavior. I now get A "Please enter passphrase" prompt when I open a .gpg file but it never seems to get past that. The prompt never goes away after entering my passphrase.
If this prompt comes from pinentry-curses, you might try:
1. enter passphrase (maybe not followed by enter, please try),
2. press tab key, 3. press enter key twice.
The reason for this is that you cannot see the whole form presented by pinentry-curses. Maybe try pinentry-curses outside emacs (and enter command GETPIN) to understand the blind navigation suggested above.
Similar problems exist if you use the Mew mail client (and gpg) inside emacs (in a terminal or tmux).
Anyone knows how to force the pinentry-curses dialog into one line suitable for emacs?
There are two main approaches, but their effectiveness may vary depending on the version of GPG used. This answer is for thecurrent modern branch (i.e. 2.2.x), not whatever was current when the question was asked.
Option 1a. Edit ~/.gnupg/gpg-agent.conf to use ncurses:
pinentry-program /usr/bin/pinentry-curses
Option 1b. Edit ~/.gnupg/gpg-agent.conf to use the Emacs pinentry (if available):
pinentry-program /usr/bin/pinentry-emacs
Option 2. Use the local gpg-agent and GUI over the SSH connection as described here
Option 2 takes a bit more effort to setup, but not too much and the benefits are considerable. Especially if you don't want to leave a secret key on a remote server.
I am trying to automate a command that prompts the users for their pin, the command in question;
tpmvscmgr.exe create /name "vSmartcard" /pin prompt /adminkey default generate
at this point you press enter, the next thing you see is
Enter Pin:
You enter the pin and press enter, then you get asked to confirm the pin before pressing enter again.
How can I automate this in a batch file, or in powershell? I haven't been able to find any commands that work in a similar way to even get a start on it.
I am not sure if the trick below work with your particular program; but even in this case, if the program prompts for an additional input it must be placed inside the parenheses next to the pin number. Perhaps this is enough for your needs...
#echo off
(
echo pinnum
echo pinnum
) | tpmvscmgr.exe create /name "vSmartcard" /pin prompt /adminkey default generate