Sponsored Content
Full Discussion: SHA1 verification script
Operating Systems OS X (Apple) SHA1 verification script Post 302991648 by Ardzii on Wednesday 15th of February 2017 05:08:30 AM
Old 02-15-2017
Apple SHA1 verification script

Hi guys!

Me again! ...
I'm trying to build (on MacOS directly) a bash script that will help me verify a SHA1 digest (to verify downloads and so on and so forth).

So first off, here's my version of BASH under OSX:
Code:
bash-4.4$

And here's my version of Sierra (macOS):
Code:
10.12.3 (16D32)

and last but not least, here's my code:

Code:
#!/usr/local/bin/bash

declare sha1=""
declare PATH=""
declare verifySha=""

echo
echo
echo
echo " Please enter the path to the file you want to check:"
read PATH
echo
echo " Now the SHA1 provided by the publisher:"
read sha1
echo
echo
verifySha=$(openssl sha1 $PATH)
if [ $sha1 -eq $verifySha ]
then
        echo "OK, same here!"
        echo
        echo
else
        echo "Not the same, try again!"
        echo
        echo
fi



Now, I know that $sha1 and $verifySha will not be the same for now... I need a sed in the middle to extract the sha signature.
But, aside from this minor problem that I will fix soon, I get the error:
Code:
./shaVerif.sh: line 17: openssl: command not found
./shaVerif.sh: line 18: [: 7798b65ae8842768bd2ff068545e0a3fc2dd0140: unary operator expected

Anyone has any idea why the openssl command does not work in a bash script? (Obviously, when I try to pass the command outside of the script, it works!).
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

verification?

I'm really new at this and wondering how I would go about adding code to my script to verify that all records loaded successfully? (I am loading a file into a table) i'm using the Korn shell. I'm also having trouble verifying parts in the header as i do not really understand the header and... (3 Replies)
Discussion started by: sheranjem
3 Replies

2. UNIX for Dummies Questions & Answers

Verification of a script already running - where to do it

Hi, I have a script I want to run as a background process. Where would I add a bit of script so that a check can be performed to see it this is already running and, where it isn't, to then run it? I know how to do this... I just don't know where I can put the initial part of the check script so... (2 Replies)
Discussion started by: miwinter
2 Replies

3. Shell Programming and Scripting

Email address verification script

Hi Group, Please forgive in case this is discussed. I need help regarding a simple script to verify if the give address exist in the Ldap directory. If the email exists the script should exit with a 0 status or else a non zero status. I am currently using the following script (and it is... (4 Replies)
Discussion started by: Ramdas
4 Replies

4. Shell Programming and Scripting

parse csv file, sha1 hash and output

I have a file, not really a csv, but containing delineated data just the same. Lets call that file "raw_data.txt". It contains data in the format of company name:fein number like this: first company name:123456789 second company name:987654321 what i need to do is read this file, apply... (11 Replies)
Discussion started by: FreddyG
11 Replies

5. Programming

SHA1 hash calculation

hi i want to generate SHA1 hash of string in Linux (atmark) and downloaded the XYSSL-0.9 version code for the same.i have the algorithm which takes file as argument and returns hash of file . And of same file while I generated the key using online tools then it doesn't match with my compiled... (4 Replies)
Discussion started by: ahsaas42
4 Replies

6. Shell Programming and Scripting

Script for verification of Data corruption

Hi, I am from File system back ground and doing File system testing on Linux, I need script that scirpt that create the different multiple types of .txt, device file and then copy to mount point /mnt/ dir and then verify the created files and copied files, if created files and copied files are... (4 Replies)
Discussion started by: manish_tcs_hp
4 Replies

7. Shell Programming and Scripting

sha1 question

What is the unix shell scripting equivalent of the following php code? I have tried to reproduce it, but I haven't been able to. <?php sha1(sha1(strtolower($user) . $pass) . $sessionid); ?> (12 Replies)
Discussion started by: locoroco
12 Replies

8. Shell Programming and Scripting

Script Verification

Hi eveyone I am planning to use crontab to delete all files in my donwloads directory that are older than one hour I will be using crontab to run this script find /home/kee/downloads/* -daystart -mmin +59 -type f -name -exec rm -r {}\; could you please let me know if the above... (1 Reply)
Discussion started by: k33k00
1 Replies

9. Shell Programming and Scripting

Verification on shell script

hello i have writing a shell script to download and run some packages the only way that i use to verify download pack is , limit users ip to download from main server, if wget can download file (verified) then script run by execute it sh pack76.sh else show and error (stupid solution ha?) ... (8 Replies)
Discussion started by: nimafire
8 Replies

10. Shell Programming and Scripting

Field verification script help

Hello again unix.com I need some help regarding a script. I have: function checkform ( form ) { if (form.pass.value.length < 6) { alert( "Error." ); form.pass.focus(); document.getElementById('pass').style.backgroundColor="#FFFFFF"; return... (2 Replies)
Discussion started by: galford
2 Replies
MSSQL_FETCH_FIELD(3)													      MSSQL_FETCH_FIELD(3)

mssql_fetch_field - Get field information

SYNOPSIS
object mssql_fetch_field (resource $result, [int $field_offset = -1]) DESCRIPTION
mssql_fetch_field(3) can be used in order to obtain information about fields in a certain query result. PARAMETERS
o $result - The result resource that is being evaluated. This result comes from a call to mssql_query(3). o $field_offset - The numerical field offset. If the field offset is not specified, the next field that was not yet retrieved by this function is retrieved. The $field_offset starts at 0. RETURN VALUES
Returns an object containing field information. The properties of the object are: o name - column name. if the column is a result of a function, this property is set to computed#N, where #N is a serial number. o column_source - the table from which the column was taken o max_length - maximum length of the column o numeric - 1 if the column is numeric o type - the column type. EXAMPLES
Example #1 mssql_fetch_field(3) example <?php // Connect to MSSQL and select the database mssql_connect('MANGOSQLEXPRESS', 'sa', 'phpfi'); mssql_select_db('php'); // Send a select query to MSSQL $query = mssql_query('SELECT * FROM [php].[dbo].[persons]'); // Construct table echo '<h3>Table structure for 'persons'</h3>'; echo '<table border="1">'; // Table header echo '<thead>'; echo '<tr>'; echo '<td>Field name</td>'; echo '<td>Data type</td>'; echo '<td>Max length</td>'; echo '</tr>'; echo '</thead>'; // Dump all fields echo '<tbody>'; for ($i = 0; $i < mssql_num_fields($query); ++$i) { // Fetch the field information $field = mssql_fetch_field($query, $i); // Print the row echo '<tr>'; echo '<td>' . $field->name . '</td>'; echo '<td>' . strtoupper($field->type) . '</td>'; echo '<td>' . $field->max_length . '</td>'; echo '</tr>'; } echo '</tbody>'; echo '</table>'; // Free the query result mssql_free_result($query); ?> SEE ALSO
mssql_field_seek(3). PHP Documentation Group MSSQL_FETCH_FIELD(3)
All times are GMT -4. The time now is 07:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy