0

I'm using a Windows command file:

@Echo Off
MODE con:cols=5000 lines=80
cmd /k "title & x:\dir\Putty\PLINK.EXE -ssh name@connection tail -f /opt/dir1/dir2/Blabla_Debug.log"

This works like a charm. It's executable from my client and gives me a tail on the logfile and a decent header in the cmd-box (so I know what I'm looking at).

But now I want to execute a grep on the logfile.

I've tried to add '| grep text' (without the quotes) but that results in an error (in the command box): 'grep' is not recognized as an internal or external command.

So what I've tried is:

cmd /k "title & x:\dir\Putty\PLINK.EXE -ssh name@connection tail -f /opt/dir1/dir2/Blabla_Debug.log | grep text" 
  • you need to get the grep to be part of the ssh command; wrap single quotes around the tail and grep – Jeff Schaller Feb 3 '17 at 16:21
0

In your example, the argument of the title command is missed

cmd.exe /k "title dnslogger & PLINK.EXE -ssh root@xenial.local tail -f /var/log/dnsmasq.log | grep -v DHCP"
| improve this answer | |
  • Thanks for your reaction, unfortunately that doesn't help. Still the same error. – Vince Feb 7 '17 at 8:31
  • Windows Version and Version of cmd.exe? Please post the output from cmd.exe /k ver – ingopingo Feb 11 '17 at 16:07
  • I'm using: Windows 2008 R2 Result of cmd.exe /k ver is [Version 6.1.7601] – Vince Feb 20 '17 at 9:36
  • Create a textfile with the complete shell command, for example logintail.sh with the command line as content tail -f /var/log/mail.log | stdbuf -o0 grep Login:. The plink command is now PLINK.EXE -batch -ssh -agent -i mykey.ppk -m logintail.sh you@yourserver.local. It works on 2008R2. – ingopingo Feb 21 '17 at 18:40
  • nice! Creating a script.sh file on the Windows site was something I didn't think of. It's working. Even with the cmd /k "title .... feature. – Vince Feb 23 '17 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.