Continuous 'tail' command

Advertisement

lhannay
Donor
Joined:
Posts:
1

Continuous 'tail' command

Hi,

I have set up 'tail --lines 50 myfilename' as a custom command and it works great. However, when I try to make it continuous, i.e. by adding the '-f' or '--follow' option it doesn't work; instead it aborts with a timeout error.

Is there any way to get the tail command to be more than a one-shot deal?

Thanks,
Larry

Reply with quote

Advertisement

Danny D
Guest

Feature request?

While trying to do the same (tail -f "!") I came across the same problem and found this thread.

What I'd like to to is to monitor log files with one click. Right now the only solution is to open a Putty session, browse to the path of the file in question and then tail -f.

I could imagine tree solutions:
1. Pipe the output of "tail -f" into the terminal window
2. Add a "follow" feature to the internal editor of WinSCP
3. Allow the user to set up an external tail program (e.g. http://www.baremetalsoft.com/baretail/index.php), just like an external editor

Would there be any chance to have one of the solutions above added to the wish list? I have no particular preference regarding the solution.

Hm, thinking about it: a "add Putty session here" in the context menu of folders would also be a nice addition (just like "Command Prompt Here" on Windows).

Thanks
Danny

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,253
Location:
Prague, Czechia

Re: Feature request?

Danny D wrote:

1. Pipe the output of "tail -f" into the terminal window
This is impossible for technical reasons.

2. Add a "follow" feature to the internal editor of WinSCP
3. Allow the user to set up an external tail program (e.g. http://www.baremetalsoft.com/baretail/index.php), just like an external editor
This request has been added to tracker.

Hm, thinking about it: a "add Putty session here" in the context menu of folders would also be a nice addition (just like "Command Prompt Here" on Windows).
There's no way to tell PuTTY (or SSH terminal in general) in which directory it should start.

Reply with quote

kka
Guest

better late, then never

cmd /c start cmd /c c:\tools\putty\PLINK.EXE -load "WinSCP temporary session" -pw yourpass tail -f "!/!" :mrgreen:

Reply with quote

Advertisement

kka
Guest

thanks for your reply martin, but I don't understand how connection timeout correspond with ability to one button tail log file.
I find it very usefull, when I have to dig log files on an SSH connected hardware for errors

Tail File custom command button v.2.0, now with file name title :)


cmd /c start "!/!" cmd /c c:\tools\putty\PLINK.EXE -load "WinSCP temporary session" -pw Qwerty123 tail -f "!/!" 

Reply with quote

Advertisement

Pathduck
Donor
Pathduck avatar
Joined:
Posts:
82
Location:
Oslo

That's really awesome - I've been wondering if such a thing was possible, just shows how much versatility WinSCP has :D

I've changed mine a bit since I often have several connections open and loading the temporary sessions does not work then.

cmd /c start "!/!" "%userprofile%\bin\putty\plink.exe" !U@!@:!# tail -f "!/!"

Port (!#) is good to have since it's not always 22 ;)
Also I use key-autentication a lot so I don't need to save the password in the session file.

Reply with quote

martin
Site Admin
martin avatar

Pathduck wrote:

I've changed mine a bit since I often have several connections open and loading the temporary sessions does not work then.
Why wouldn't it work?

Reply with quote

Pathduck
Donor
Pathduck avatar
Joined:
Posts:
82
Location:
Oslo

martin wrote:

Pathduck wrote:

I've changed mine a bit since I often have several connections open and loading the temporary sessions does not work then.
Why wouldn't it work?

Actually, I'm not sure :)
I mean, I tested and it failed on that it couldn't find the temporary session. I think I'll need to test it some more, as it seems to work fine now on the home system, so not sure what happened.

Isn't the "Winscp temporary session" overwritten in registry on each new connection? Or maybe it gets overwritten on changing connected tabs?

Reply with quote

Pathduck
Donor
Pathduck avatar
Joined:
Posts:
82
Location:
Oslo

Update: So I did a little test and changed the tail command to "hostname; sleep 10" to find what host the temporary session pointed to. It output the host name of the last host I used ctrl+P on.

I think (only a theory) that the session entry will always be pointing to the last host you used Ctrl+P on, as that's when it gets changed. So when plink load the session it only loads the last host you opened putty on?

Might be something weird here at work, Windows Server 2008R2, and I don't have access to regedit so can't verify what happens in there. Also using WinSCP dev build 5.10 7416 so that might be a thing.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,253
Location:
Prague, Czechia

Pathduck wrote:

Update: So I did a little test and changed the tail command to "hostname; sleep 10" to find what host the temporary session pointed to. It output the host name of the last host I used ctrl+P on.

I think (only a theory) that the session entry will always be pointing to the last host you used Ctrl+P on, as that's when it gets changed. So when plink load the session it only loads the last host you opened putty on?

Might be something weird here at work, Windows Server 2008R2, and I don't have access to regedit so can't verify what happens in there. Also using WinSCP dev build 5.10 7416 so that might be a thing.
Sorry, of course! I've forgot that this is about custom command and not PuTTY command.

I've updated the documentation to use the patterns.
https://winscp.net/eng/docs/custom_commands#tail

Though note that the :!# is wrong. It does not do, what you think. You have to use -P !#.

Reply with quote

aaronthompson@...
Guest

Re: better late, then never

kka wrote:

cmd /c start cmd /c c:\tools\putty\PLINK.EXE -load "WinSCP temporary session" -pw yourpass tail -f "!/!" :mrgreen:

I didn't get this to work, but this works for me:
cmd /C ""c:\Program Files\putty\PLINK.EXE" -load "savedsession" -l myusername -pw mypassword tail -f myRemoteLogFile"

Reply with quote

Advertisement

You can post new topics in this forum