Tag Archives: Shell Script

Submit Google Forms by curl command

Google Forms is a very common way to collect user data nowadays. After you have created the form, you could insert it to your web site and present it with your own style.

Other than that, we could integrate Google Forms with the backend job since we could submit the form through command line. Let’s take a look on the following example.

1. Create a new form on your Google drive. The edit page url should be in the following format.

  • https://docs.google.com/forms/d/<form-id>/edit

Continue reading Submit Google Forms by curl command

Jenkins – Get the build user name in job config

I would like to get the username who triggered the Jenkins job in the Post build task. At first i thought the Build User Vars Plugin could work but than i realize those variables are only available in the Build process but not the post build action.

Luckily, i found a blog post written by Donald Simpson which help me to solve the problem.

Continue reading Jenkins – Get the build user name in job config

Shell Script – Check file owner and other attributes

Here is a simple shell script which would read a user input and return you the owner and group of the input path.

check_owner_and_group.sh

#!/bin/sh

echo "Please enter a file/folder path:"
read target_path
echo "You have entered $target_path"

if [ -e $target_path ]; then
  target_owner=$(stat -c %U $target_path)
  target_group=$(stat -c %G $target_path)

  echo "$target_path owner is: $target_owner"
  echo "$target_path group is: $target_group"
else
  echo "$target_path is not a valid path"
fi

Continue reading Shell Script – Check file owner and other attributes

Java – Date validation using SimpleDateFormat

I need to write a program which reads a date string. The program then archives all the data on the server with the input date as an cut off date.

The following java program is based on the tutorial in </dream.in.code>. It reads a date string, validate it and print the number of date difference between today and the input date.
Continue reading Java – Date validation using SimpleDateFormat