Shell & Cmd

Site about shell scripting and windows scripting

In shell we can almost everything. But let’s divide issue into 3 part: LINES, WORDS, CHARACTERS Part 1 – Lines Q. How to create histogram of lines? Test file [root@hostname]# cat test aaaa aaaa aaaa bb bb cccccc dddd dddd dddd dddd The answer is uniq – great unix command, below some examples, the last on is the best [root@hostname]# cat test | uniq -c       3 aaaa       2   Read More ...

unix

Task: Create environment for downloading files.   Limtations: - open port 22 - protocol scp - exchanged ssh keys   Platform: - Linux, AIX, HPUX, SunOS, Windows 2000, Windows 2003, Windows 2008 Start Simple remedy is to create chrooted user which hosts some files. In Network we can easly find some ready-made solutions like: SCPONLY https://github.com/scponly RSSH http://www.pizzashack.org/rssh/ But since OpenSSH 4.8 (http://www.openssh.com/txt/release-4.8) Added chroot support for sshd, controlled by   Read More ...

unix

    Today some useful aliases. First of all definition: In computing, alias is a command in various command line interpreters (shells) such as Unix shells, 4DOS/4NT and Windows PowerShell, which enables a replacement of a word by another string. It is mainly used for abbreviating a system command, or for adding default arguments to a regularly used command. Aliasing functionality in the MS-DOS and Microsoft Windows operating systems is   Read More ...

unix

For many times, I was wondering haw to add progress bar to some loops operations, ie, ping many hosts, copy many files. Of course there is lot of possibilities to archive this. In this part I show two examples using bat files First example: @ECHO OFF REM INICIAL VAL SET i=1 ECHO Start :START CALL :ShowProgres %I%     REM ADD SOME OPERATIONS     ping -n 1 -w 1 127.0.0.1>NUL SET   Read More ...

windows

The question is: How to display process list in Windows and Unix? The answer is: Very simply, two command: ps (Unix) and tasklist (Windows) And examples.   Unix ps – report a snapshot of the current processes.   [user@hostname ~]$ ps -ef|grep httpd apache   11989 18736  0 Jan31 ?        00:00:00 /usr/sbin/httpd apache   12020 18736  0 Jan31 ?        00:00:00 /usr/sbin/httpd apache   12021 18736  0 Jan31 ?        00:00:00 /usr/sbin/httpd apache   16229 18736    Read More ...

unix , windows

The question is very simple and the answer could be. Basic approach [Unix]: tree -d which “List the contents of directories in a tree-like format.” And output [root@hostname etc]# tree -d . |-- NetworkManager |   |-- VPN |   `-- dispatcher.d |-- X11 |   |-- applnk |   |-- fs |   |-- mwm |   |-- serverconfig |   |-- sysconfig |   |-- twm |   `-- xinit |       |-- Xclients.d |       `-- xinitrc.d |--   Read More ...

unix , windows

It’s true, on windows exists for loop, so as it is in this sentence: In computer science a for loop is a programming language statement which allows code to be repeatedly executed. on windows we can. It’s rather complex, there are a lot of syntaxes but, easy let’s start explaining. Syntax 1 – List FOR %%PARAM IN ([set]) DO CMD and example1 FOR %%P IN (item1 item2 item3 item4 item5)   Read More ...

windows

On Windows there is several different methods to obtain this. First is echo quit | telnet <hosntame> <port> And little snippet, when we are assuming that list of servers are store in file list.txt and port is 222 (why not?) for /F "tokens=*" %A in (list.txt) do @echo quit | telnet %A 222

windows

This is a common tasks, and common question: How to check open ports on remote servers. Let’s assume than we have a servers list /tmp/list We can use a command nc on unix servers #!/bin/sh listfile=/tmp/list timeout=5 port=80 for item in `cat $listfile` do nc -v -w $timeout $item $port done It’s better than telnet because of possibility of using timeout params, which doesn’t exists in case of telnet On   Read More ...

unix

I would like to show some interesting options of command date date +'%F %X' 2012-01-23 04:06:21 PM It works on Linux, SunOS, AIX and HP-UX. On windows there are two commands date /t time /t but of course you should join output.

unix , windows

Sponsors