Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello

Im completly noob with this kind of code, someone can explain to me this code? i think this code compare the serial number. but i dont undestand it line by line.

if [ -f /opt/k/newApp/kCfg.jar ]; 
then 
   sudo mv /opt/k/newApp/kCfg.jar /opt/k/kCfg.jar 
fi 
sn=$(grep -Po '^Serial\s*:\s*\K[[:xdigit:]]{16}' /proc/cpuinfo) 
sudo java -jar /opt/ka/kCfg.jar -S$sn & 
chromium -kiosk -incognito http://testserver/Default.aspx?serial=$sn


thanks

What I have tried:

i think this code compare the serial number. but i dont undestand it line by line.
Posted
Updated 7-Jan-19 4:37am

1 solution

That's pretty straight forward shell script:

the [ -f ... ] expression is a test, in this case -f tests for file existence (see man test)
if the test succeeds, then we get root privileges via sudo and move the new executable into position

This line
C++
sn=$(grep -Po '^Serial\s*:\s*\K[[:xdigit:]]{16}' /proc/cpuinfo)
runs grep's the /proc/cpuinfo file in a sub shell (that's what $() does, also written with back-ticks ``) for the serial number and assigns the value to variable sn
we then run a java program, again as root
and finally, we run chromium in kiosk mode, starting an incognito page at starting from the web site given.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900