Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

// request.cf · coarse context

A page that knows where it met you.

Only coarse request metadata is shown. This demo does not display or persist visitor IP addresses.

Country
US
Cloudflare location
CMH
Connection
HTTP/2
Language
Not provided

Ray ID: a26262105a8daddf

Jump to content

Wikipedia:Reference desk/Archives/Computing/2015 October 2

From Wikipedia, the free encyclopedia
Computing desk
< October 1 << Sep | October | Nov >> October 3 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


October 2

[edit]

What makes ssh time out?

[edit]

When I log into an Ubuntu Linux box on my home network via ssh (from a Cygwin/Windows box nearby), I find that my sessions time out after some large amount of time (at least 30 minutes...maybe hours?) when I'm not actively using them. When I do the same thing to a Linux box on the other side of the planet run by my ISP, the timeout is MUCH shorter - so evidently this timeout can be adjusted on the server-side. How do I do that? SteveBaker (talk) 14:02, 2 October 2015 (UTC)reply

On my OSX system, man sshd_config returns in part:
This suggests to me that adding the lines

ClientAliveInterval 600 ClientAliveCountMax 3

to /etc/ssh/sshd_config (or someplace analogous)
should give you an timeout of 30 minutes. I have not tested this and know nothing of the vagaries of different sshd distributions, versions, etc. SemanticMantis (talk) 14:44, 2 October 2015 (UTC)reply
And, for cases where you are not the server administrator, you can configure the client to perform keepalives: ssh_config may include the ServerAliveInterval option:
It's up to you to decide if you want to configure the server, or the client, or both... there are usually no problems if keepalives are sent in both directions.
Nimur (talk) 15:01, 2 October 2015 (UTC)reply
I've always wondered about this, but (slothful me) never delved into it to figure it out. The poor-man's solution I sometimes use is a little one-off ad-hoc keepalive pinger, invoked on the remote system:
while sleep 60; do echo 00 | unhex; done &
(where unhex is a little hex-to-binary filter that's been sitting in my personal bin directory since 1981 or so). This sends an invisible null character down the line once a minute, and usually works to keep the connection from timing out. (And even if I did know the magic sshd option to keep sessions from timing out, but the relevant machine wasn't under my control, I might still choose to use this user-level workaround.) —Steve Summit (talk) 13:17, 3 October 2015 (UTC)reply

Mass rename / format files

[edit]

Somehow, I've managed to remove the name and extension of over 400 photos and video files. So I'm stuck with files name 1,2,3 without the corresponding prefix to denote what type of file they actually are. Is there some way I can undo this or set them back up.

Trouble is, I can't really determine which files are videos or just pictures. --80.195.27.47 (talk) 15:16, 2 October 2015 (UTC)reply

Yikes! Realistically, it is probably faster for you to use a batch renaming tool to fix the bulk of the file names and extensions; then manually sort these files and rename the rest one-by-one, using guess-and-check to fix any incorrect file extensions. If you're really proficient, tools like file (command) can make educated guesses about file types... a script can wrap that command and automate your work... but I'd bet you'll spend more time learning to use it efficiently than manually modifying 400 files. If this is a problem that you never expect to need to solve again, the slow and arduous process of hand-correcting each file might really be the fastest way out.
If you are on Windows (... I make this presumption based on the new filenames you accidentally created!)... you might find the software mp3tag useful. Canonically, it is designed for batch modification and renaming of music files, but if I recall correctly, it will happily rename any other file type. It has a "regular expression"-style, wildcard-substitution file naming utility that will be more familiar to Windows users than many of the more general purpose, Unix-esque batch file manager softwares.
Nimur (talk) 17:07, 2 October 2015 (UTC)reply
I suppose you did not wanted to say prefix, but suffix, in reference to the file extension. Scicurious (talk) 18:56, 2 October 2015 (UTC)reply

Batch renaming is the easy part. Figuring out which are which is more challenging. Taking the harder part first:

The simplest solution that might work, depending on your OS settings and the original filetypes, would be to rename all of the files to be images (e.g. .jpg) then load thumbnails in your file explorer/viewer. If you're lucky, the ones that aren't images won't display properly. If they all display, try the same technique but with a video extension. If that works, skip the next paragraph.

If that didn't work, sort the files by size. This will cut down on some of the guesswork. If they were all taken with the same camera with the same settings, the size of the images will be relatively similar. In some cases, they'll might even be the same. Video files won't be so consistent, so look for patterns, moving those that look like video files out to a separate directory. You'll have to do some trial and error for videos that are about the size of images.

The renaming part. Operating under the assumption of Windows, open the directory with your presumed images. Holding CTRL-SHIFT, right click in an open part of the directory (i.e. don't click on a file) and select "Open command window here". In the console, you want the "rename" command. So if all of your files have no extension and you want them all to be .jpg, just type "rename *. *.jpg" (without quotes). If they're all jpg and you want them to be .mov, you would do "rename *.jpg *.mov". Good luck! Rhododendrites talk \\ 22:00, 2 October 2015 (UTC)reply

Rhododendrites' suggestion is a good one. To make it even easier, use XnView as your file browser. It will display a thumbnail for an image named "*.jpg" whether it's a jpeg or a png, but it will only show relevant information (confirmation of file type, geometry) if you've named it correctly. So there you have sorted your files into jpegs, pngs and the rest. Then sort by size from XnView, which will enable you to mark a large group of files of the same type. Move the files into separate subdirectories from XnView. I believe XnView handles some raw formats too, such as Canon's *.CR2. If you then name the remainder *.mov, thumbnails will appear, but no information. Move to "Mov" subdirectory. I've only tried this with *.mov's recorded with a Canon SLR. Do the renaming from the command line, as described above. I just did this with a bunch of files that I had copied from my photograph directory for the experiment. A mixture of 170 jpegs, pngs and movs, that I had renamed 1001, 1002, 1003 etc, and it took less than 15 minutes. edit: Worked with AVI's from another camera, too. --NorwegianBlue talk 22:15, 4 October 2015 (UTC)reply