Skip to main content

Posts

Showing posts with the label shell scripting

Shell script to wait until your site becomes reachable and returns code 200

Sometimes you don't know when a server becomes reachable and you just need to wait, while continuously pinging it with a certain interval. This is a shell script that does everything for you (including a timeout if host is not available during a specified period of time). It accepts two parameters: hostname of your site and a timeout in seconds.

Accepting long options with getopts in your shell script

Normally you can only have single-character options when processing your arguments with a standard getopts utility in Linux or Mac OS X. You can use getopt for long options, but it is not included in the standard Mac OS X installation. So this is a trick that will allow you to simulate long options with a standard getopts, that will work on all *nix platforms without additional software installations. This function will also print a usage tip if you execute the script without parameters (or with -h parameter).

Simple fix for a common issue with Jmeter Server startup on Amazon EC2 instances

In some cases jmeter-server process cannot start because it cannot bind itself to a correct IP address, throwing "Server Failed To Start: Java.rmi.RemoteException: Cannot Start ..." exception. This issue often happens on Amazon EC2 instances. But there is a simple and straightforward solution. You just need to modify your jmeter-server shell script:

Stray process cleanup in your test automation suite

Occasionally any large test automation suite leaves some stray browser and/or webdriver processes behind during test execution. They make our test suite slower and cause other issues, for example a stray process process may hold entire directory and prevent it from cleaning. Clean test environment is very important for test isolation and prevention of false positives. This is an example of process cleanup in Linux where we find the processes in question by their names and kill them. And here is another example where we do the same process cleanup in Windows Powershell.

Setting up SFTP server in Linux Ubuntu. Command line instructions

Simple step-by-step command line instructions on setting up SFTP server in Ubuntu 12.04, based on http://www.thegeekstuff.com/2012/03/chroot-sftp-setup/ article. 1. Add 'sftpusers' group: sudo groupadd sftpusers 2. Create a home directory for 'guestuser' user that will be added at the next step: sudo mkdir /var/guestuserhomedir As the result of the above command permissions for /var/guestuserhomedir should be 755 (owner: root, group: root). 3. Create 'guestuser' user, add it to the 'sftpusers' group and set a new password for this user: sudo useradd -g sftpusers -d /var/guestuserhomedir -s /usr/sbin/nologin guestuser sudo passwd guestuser 4. Create SFTP directories and set permissions (correct permissions are important): sudo mkdir /var/sftp_upload_dir sudo mkdir /var/sftp_upload_dir/guestuser sudo mkdir /var/sftp_upload_dir/guestuser/incoming sudo chown guestuser:sftpusers /var/sftp_upload_dir/guestuser/incoming sudo chmod 777 /var/sftp_u