#This python script is to get system’s VGA monitor info import commands command = “lspci | grep VGA ” status, vgaInfo = commands.getstatusoutput(command) print “VGA info=%s” % ( vgaInfo ) which will give the output VGA info=00:02.0 VGA compatible controller: Intel Corporation Core Processor Integrated Graphics Controller (rev 18) in my system
Category Archives: shell script
[Shell Script]How to execute multiple shell commands using a single shell variable ?
To execute multiple shell commands using a single shell variable, Assign the multiple shell commands to a variable. execute the shell variable using echo eg: Find a.txt in the present directory Let the multiple commands are ls and grep Let the shell variable is cmd . cmd=$(ls | grep a.txt ) To execute the commandsContinue reading “[Shell Script]How to execute multiple shell commands using a single shell variable ?”
[Shell Script]How to find the total count of particular string in a file
Lets say the file name is file.txt . To find the total count of particular string , lets say “abc” , from the file.txt , execute the following command tr -s ‘ ‘ ‘\n’ < file.txt | grep abc | wc -l Explanation of the above command tr -s ‘ ‘ ‘\n’ Continue reading “[Shell Script]How to find the total count of particular string in a file”
[Linux][Shell script] print fibonacci series of 12 numbers
#!/bin/sh# Fibonacci series – eg:- “0 1 1 2 3 5 8 13 21 34 55 …” a=0 #First value of the seriesb=1 #Second value of the series#print the first value of the series.echo $a#print the second value of the series.echo $b#Now a small mathmatics for finding other numbers in the series . for IContinue reading “[Linux][Shell script] print fibonacci series of 12 numbers”
[Shell Script][bash]Finding factorial of a given number using shell script
#!/bin/bash #This script will print the factorial of the number passed as arguement . eg:- ./factorial.sh 4 will print 4! value number=$1 factorial=1 i=$number while [[ $i != 1 && $i != 0 ]] do factorial=`expr $factorial \* $i` i=` expr $i – 1 ` done echo “Factorial of $number is $factorial”
[Linux]How to display first few lines of a file without opening the file
Using “head” we can display n number of lines in a file without opening it head -8 filename
[Linux][Bash]how to export the commands in sbin to PATH variable
Error – ifconfig command is not found !!! lsmod command is not found !!! insmod command is not found !!! list sbin directory content ( ls /sbin). ifconfig will be there . Solution – export PATH=$PATH:/sbin Now try the commands (ifconfig , lsmod or insmod) …. 🙂 Permanent fix – Add the line export PATH=$PATH:/sbin into .bashrc file in yourContinue reading “[Linux][Bash]how to export the commands in sbin to PATH variable”
Did you hear about sha-bang ?
The Sha-bang (#!) at the head of a script tells Linux system that this file is a set of commands to be fed to the command interpreter indicated. Immediate following the sha-bang is a path-name eg:- #!/bin/bash Is it worth reading ? Please like the post if its helpful. Please give your suggestions too
What is shell script ?
Shell script is a series of command written in a plain text file. Uses of scripting Saves lots of time . For automation purpose . Is it worth reading ? Please like the post if its helpful. Please give your suggestions too
[Shell Script][Perl Script]Monitoring a process’s status in a particular time interval
Assuming process.sh is the process which is to be monitored periodically. For checking above process’s health , a script is required . Here statuscheck.sh will check whether the process.sh is running or not. If process is not running, restart the process using exec command monitor.sh will call statuscheck.sh in every particular interval(eg: here in everyContinue reading “[Shell Script][Perl Script]Monitoring a process’s status in a particular time interval”