Topic "Continuous 'tail' command"

Author Message
lhannay
[View user's profile]
Donor
Joined: 2008-03-05
Posts: 1
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
Advertisements
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26730
Location: Prague, Czechia
No, it is not possible.
_________________
Martin Prikryl
Danny D

Guest


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
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26730
Location: Prague, Czechia
Danny D wrote:
1. Pipe the output of "tail -f" into the terminal window

This is impossible for technical reasons.

Quote:
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.

Quote:
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.
_________________
Martin Prikryl
kka

Guest


cmd /c start cmd /c c:\tools\putty\PLINK.EXE -load "WinSCP temporary session" -pw yourpass tail -f "!/!" Mr. Green
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26730
Location: Prague, Czechia
That's not a kind of a task WinSCP is designed for.

Though you can simply set longer timeout:
https://winscp.net/eng/docs/ui_login_connection
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 Smile


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

Guest


martin
btw can you include this custom file command into distributive?
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26730
Location: Prague, Czechia
Thanks. I've added this to documentation:
https://winscp.net/eng/docs/custom_commands#tail
Pathduck
[View user's profile]
Donor
Joined: 2012-05-29
Posts: 76
Location: Oslo
That's really awesome - I've been wondering if such a thing was possible, just shows how much versatility WinSCP has Very Happy

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

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


Port (!#) is good to have since it's not always 22 Wink
Also I use key-autentication a lot so I don't need to save the password in the session file.
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26730
Location: Prague, Czechia
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?
Pathduck
[View user's profile]
Donor
Joined: 2012-05-29
Posts: 76
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 Smile
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?
Pathduck
[View user's profile]
Donor
Joined: 2012-05-29
Posts: 76
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.
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26730
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 !#.
Pathduck
[View user's profile]
Donor
Joined: 2012-05-29
Posts: 76
Location: Oslo
Thanks for confirming, Martin Smile

Yeah, that's right - I always assume putty/plink works the same as OpenSSH, but it appears to just ignore :portnumber so -P is needed.

Oh and to be picky - the -P !# should be before the user@host according to the doc (but after still works though):
https://the.earth.li/~sgtatham/putty/latest/htmldoc/Chapter7.html#plink-usage
Advertisements

You can post new topics in this forum

Search

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License