LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-26-2017, 03:01 AM   #1
Fergupicus
LQ Newbie
 
Registered: Sep 2017
Location: Bay of Plenty, NZ
Distribution: Debian, Kali, Fedora
Posts: 20

Rep: Reputation: 0
Checksum program is throwing out an "file not found" error?


Hello, I'm new to this forum ( hope I'm allowed to say this as on stack-exchange I'm apparently not allowed to say hi or thanks :P ) Anyway I'm creating a simple program to do check-sums as I'm trying to get a hang of bash programming (so I can get a grasp of how things work before moving on to another language. So here is a chunk of my code
Quote:
echo "Path to File?"
read Path
localsum=$(sha256sum $Path)
Now the trouble is whenever I get to this part it spits out an error saying
Quote:
sha256sum '~/Downloads/pycharm-community-2017.2.3.tar.gz':No such file or directory
I have checked multiple times that this is the correct file even going so far as to type out the code into terminal to see what happens; it turns out fine, as predicted. So my quiestion is, what am I doing wrong?

Any help would be greatly appreciated
Thanks in advance, Fergus
 
Old 09-26-2017, 07:41 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 3,321

Rep: Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008Reputation: 1008
In this context, you cannot use ~tilde in the meaning of 'my home directory'.
Try this:

Code:
cat myscript
#!/bin/sh
if [ -n "$1" ]; then
    Path="$1"
else
    echo "Path to File?"
    read Path
fi
localsum=$(sha256sum "$Path") 
./myscript ~/Downloads/pycharm-community-2017.2.3.tar.gz

Last edited by NevemTeve; 09-26-2017 at 07:42 AM.
 
2 members found this post helpful.
Old 09-26-2017, 02:52 PM   #3
Fergupicus
LQ Newbie
 
Registered: Sep 2017
Location: Bay of Plenty, NZ
Distribution: Debian, Kali, Fedora
Posts: 20

Original Poster
Rep: Reputation: 0
Oh cool, well I'v already written a the majority of my code and I've just tried an alternative: using /root/Downloads as my input instead! This worked so as this is for personal use only I'll just be doing that.

Thanks for the help, Fergus

Last edited by Fergupicus; 09-26-2017 at 02:57 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] X: "loading extension glx" "no screens found" "fatal server error" (w/ nvidia driver) Geremia Slackware 7 12-29-2014 12:00 PM
Valgrind is throwing error "failed in UME with error 22 (Invalid argument)." vamsi9042 Programming 1 11-06-2013 05:57 AM
[SOLVED] I get "'found module version 0, expected 9" Error while running a fortran 90 program. msbstar Linux - Newbie 4 09-16-2012 03:44 PM
FIX: wine error "No Program Start Menu Found" JackSmith Linux - Games 3 07-02-2009 11:38 PM
cedega install Diablo2 SuSE 91 "No program start menu found" error Drone91 Linux - Software 0 10-09-2005 01:55 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration