Saturday, April 15, 2017

posting files with curl in shell script

https://davidwalsh.name/curl-post-file

curl -X POST -F 'image=@/path/to/pictures/picture.jpg' http://domain.tld/upload


Authenticate Alfresco Using POST method in shell script

#!/bin/bash






curl -X POST -H 'Content-Type:application/json' -d '{"username":"admin","password":"admin"}' http://192.168.1.4:8081/alfresco/s/api/login

Authenticate Alfresco Using shell script

#!/bin/bash


curl -X  GET 'http://192.168.1.4:8081/alfresco/s/api/login?u=admin&pw=admin'

Sunday, April 9, 2017

parse calendar shell script

#!/bin/sh
cal 2 1997
output=$(cal 2 1997);

while read line;do
echo "Printing Each Line";
echo "$line";
word=$(echo $line | tr " " "\n");
set $word;
echo "Printing Each Day In Row";
echo $1
echo $2
echo $3
echo $4
echo $5
echo $6
echo $7
done<<<"$output";

connect to RestAPI shell script

#!/bin/sh
curl -sb -H "Accept:application/json" http://www.thomas-bayer.com/sqlrest/CUSTOMER/3/

find list of firefox processes and terminate shell script


#!/bin/bash
output=$(ps -ef|grep firefox)
linesCount=0;
while read lines;do
((linesCount++));
echo "$lines";

word=$(echo $lines | tr " " "\n");
wordCount=0;
for wordArr in $word;do
((wordCount++));

if [ $wordCount -eq 2 ]
then
kill -9  $wordArr;
fi
done





done<<<"${output}"

Extract List of fileName from ls command shell script


#!/bin/bash
output=$(ls -l)
linesCount=0;
while read lines;do
((linesCount++));
if [ "$linesCount" -ne 1 ]
then

word=$(echo $lines | tr " " "\n");
wordCount=0;
for wordArr in $word;do
((wordCount++));
if [ $wordCount -eq 9 ]
then
echo $wordArr;
fi
done
fi





done<<<"${output}"

Count number of lines in a file shell script

#!/bin/bash



count=0;
while read lines;do
((count++));




done<"/home/rajam/name.txt"


echo "Number OfLines In a file";
echo "$count"

Wednesday, April 5, 2017

what is MapReduce Algorithm

MapReduce is a programming model and an associated implementation for processing and generating big data sets with a paralleldistributed algorithm on a cluster

  • "Map" step: Each worker node applies the "map()" function to the local data, and writes the output to a temporary storage. A master node ensures that only one copy of redundant input data is processed.
  • "Shuffle" step: Worker nodes redistribute data based on the output keys (produced by the "map()" function), such that all data belonging to one key is located on the same worker node.
  • "Reduce" step: Worker nodes now process each group of output data, per key, in parallel.

credit goes to wikepedia

Monday, April 3, 2017

How do u parse Calendar in ShellScript

#!/bin/sh
cal 2 1997
output=$(cal 2 1997);

while read line;do
echo "Printing Each Line";
echo "$line";
word=$(echo $line | tr " " "\n");
set $word;
echo "Printing Each Day In Row";
echo $1
echo $2
echo $3
echo $4
echo $5
echo $6
echo $7
done<<<"$output";

Saturday, April 1, 2017

what is /etc/passwd in unix?

whenever we create password for the user in unix ,unix stores password in a file in a location /etc/passwd

etc is the directory
passwd is the name of file

what is ulimit in unix?

ulimit contains a value which signifies the largest file that can be created by the user in the file system

default ulimit for ubuntu is unlimited