Sep 252016
 

I'm just putting here this command to remember it next time when I need it.

Problem to be solved

When SD card of my photo camera is full I just upload the photos to my NAS server NSA320 . After that usually I do some cleanup and one of the steps is to move the video (there are not only photos)  files from the the photo/ directory to other location.

Until now I did this step manually, to save time I was thinking to make it automatic.

Solution

This is what I want to do:

  1. Get shell access on my NSA320 , to do this I've installed ffp (Fonz fun_plug). It is a collection of packages for NSA320 that includes a ssh server.
  2. After geting ssh access in step 1, I need to create a small scrip to move all the video files from $SOURCE_DIR to $DST_DIR. All video means files with next extensions:
    • .MOV (has to be no case sensitive)
    • .MPG/MP4 (has to be no case sensitive)
    • .AVI (has to be no case sensitive)

I'm using rsync command.

rsync -rav --remove-source-files --exclude '*' --include '*/' --include '*.[Mm][Oo][Vv]' --include '*.[Mm][pP][4gG]' --include '*.[Aa][Vv][Ii]'  --prune-empty-dirs $SOURCE_DIR  $DST_DIR

The meaning of the arguments:

  • -r = to go recursively on the entire $SOURCE_DIR
  • -a = archive mode, it means to preserve most of the attributes of the files. For me important was last modified time
  • -v = verbose; I just wanted to have a list with files that have been moved.
  • --remove-source-files = to remove from source dir the files that have been copied to destination.
  • --exclude '*' = by default exclude all files; except the one passed to "--include" switches
  • --include '*/' =  include directories in teh list of files that have to be moved
  • --include '*.[Mm][Oo][Vv]' = include files with .MOV extension; no case sensitive. Similar for .MPG, .MP4, .AVI
  • --prune-empty-dirs = do not copy empty dirs from source to destination

At the end of the command you will noticed something like this:

sent 24287985339 bytes received 8458 bytes 12766356.79 bytes/sec
total size is 24511383985 speedup is 1.01

On my NSA320 it took few minutes to move ~23GB.

 Posted by at 10:18 AM
Jan 182014
 

Small tip for virtualbox: how you can enable copy (and paste) from host to guest and from guest to host.

Most when playing with virtual machines you would like to copy pieces of code from host machine to guest OS and vice versa.

By default after installing virtual box, this feature is not activated, but can be enabled very easy.
In the main menu of the windows where the guest OS is running is a submenu "Devices".
Just select Devices -> Sharecropped -> Bidirectional ; like  in the picture bellow.

Virtualbox enable shared clipboard

Virtualbox enable shared clipboard

And now the copy -> paste should work without any problem.

E.g. you just found on the net an interesting piece of code browsing from host OS, but net is not enabled on the guest OS; now you can test it just doing copy->paste.

Keep in mind that this setting is for virtual machine. So, if you will play other image of a VM, you have to do the same settings.

 Posted by at 10:17 PM
Aug 232013
 

Very often from TCL scripts we may want to execute external commands.
But not always they also available, sometime the command that we want to execute may not exist on the respective machine.
One solution is to put the exec command in a catch { exect $your_command $arg1 $arg2 ... } and then to check if it was successfully.

The problem here is that you have to write few lines of code to check if the command is missing, or the arguments passed were wrong.

Other solution, more elegant I think, is to use auto_execok procedure to check if your command really exists, something like bellow:

% set ls_cmd_path [auto_execok ls]
/bin/ls
% puts $ls_cmd_path
/bin/ls
% set ls_cmd_path [auto_execok ls_wrong]
% puts $ls_cmd_path 

%

So, just call the set result [auto_execok $your_command]  and check if the result is not empty string to see if the command really exists.

 

Aug 202013
 

One of the most difficult task to do in tcsh is to  redirect the stdout and stderr into separated files. I'm not doing this very often, and because of this I always forget how to do it. Every time when I need to do such a thing I spend tens of minutes trying different combination and reading man/internet pages.

On other shells like bash it is straight forward: my_command > out.txt 2> err.txt  . Such a thing will not work in tcsh, but hey the things are not so complicated. You just have to do (my_command > out.txt ) >& err.txt . Even more, if you want to redirect only the stderr to a file , and want to see what is originally printed on stdout you can do like this: (my_command > /dev/tty ) >& err.txt

Hope that the trick is useful for other visitors who came to this page.

Aug 122012
 

Since years I'm using the putty as ssh client, and I think that it is one of best ever done.
Anyway in the last time I was searching for a SSH client which can handle multiple ssh sessions on the same running instance, to not switch between different windows.

I was looking for something at low cost, but if it is free then it is even better.
Finally I found something: it is mobaxterm from mobatek .
It has what I wanted: tabbed sessions.
If you have multiple connections you do not need to switch between multiple windows, they are tabbed under the same main application.
mobaxterm SFTP tab

    Also, mobaXterm has a lot of other feature, most used be my are:

  • SFTP connection, all he time when you open a ssh connection you will get a SFTP connection too. Continue reading »
 Posted by at 9:55 PM