Previously we talked about how to submit a Google Form by the curl command.
In the url, we have to encode the special characters such as whitespace. In shell script, we could do string replace as follow.
${VariableName//Pattern/Replacement}
Previously we talked about how to submit a Google Form by the curl command.
In the url, we have to encode the special characters such as whitespace. In shell script, we could do string replace as follow.
${VariableName//Pattern/Replacement}
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.
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
This is an example shell script which creates a file with datetime as filename.
eureka.sh
#!/bin/bash echo "Eureka!" > eureka.$(date '+%Y-%m-%d').txt
Done =)
Reference: StackOverflow – linux redirector to log filename with $date variable
Recently, i have a new task which is adding a user account on a Linux box with UI login shell. My project leader suggests a few tools for me to study and finally i pick the the one called pdmenu.
Continue reading Dialog – Create a Simple Menu for Inexperienced Linux Users
In the housekeeping shell script, i would update some files. The following example will try to update the /tmp/test file and display the result.
Continue reading Shell Script – Check if a file is updated
Except checking whether the folder is empty or not, i would also like to know whether the *.log files are removed. Here is another example.
Continue reading Shell Script – Check the existence of files which have common file name
I am working on a housekeeping shell script to delete old files and update some files. I want to know whether the .sh is completed without problem. So i made a checking part in the shell script.
Continue reading Shell Script – Check Empty Folder
Usually, we have to manipulate the file time attributes in the shell script in order to complete the task. Just like the example at Shell Script – Delete Old Files
Continue reading Shell Script – stat
For housekeeping the backup files on a server, we can write a shell script to remove files which were created some days ago and scheduled it by cron job.
The following code is an example to remove backup files which were created 90 days ago. Please note that the target folder is just the same as the .sh file location and the .sh file is excluded in the command.
Continue reading Shell Script – Delete Old Files