LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-15-2014, 04:41 PM   #1
rivelino90
LQ Newbie
 
Registered: Jan 2014
Posts: 6

Rep: Reputation: Disabled
help


create a script that takes as an argument the path of a text file and encrypts it with command gpg. the script should consider when the file doesn't exists
 
Old 01-15-2014, 04:48 PM   #2
mutput7
LQ Newbie
 
Registered: Oct 2012
Location: A magical place full of Canadian dirt.
Distribution: Arch Linux
Posts: 12

Rep: Reputation: 4
First of all, work on writing titles that might help people to see your post. (See MensaWater's post after this one, seriously.)
Second:
Code:
#!/bin/bash
if [ -f $1 ]; then
  cat $1 | gpg --encrypt
else
  echo "error: Could not read input file. Does it really exist? Is it a directory?"
  echo "Usage: $0 <file>"
  echo
  echo "file: the file you wish to encrypt"
fi
But this should've taken maybe ten minutes of actually learning things to figure out, even if you've never used bash.

Last edited by mutput7; 01-15-2014 at 04:54 PM.
 
1 members found this post helpful.
Old 01-15-2014, 04:48 PM   #3
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,580
Blog Entries: 14

Rep: Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969
You really shouldn't title your post with "help". The purpose of this site is to "help". Putting a valid title on it might help people in the future to find your post and any resolution thereof.

Your question sounds suspiciously like a homework assignment in which case you should try it yourself then ask questions at points you don't understand something or it doesn't work the way you expect.

Passing arguments into bash (or ksh or sh or posix sh) is easy. I'd suggest you have a look at the discussion here:
http://linux.about.com/od/Bash_Scrip...ash-Script.htm

Using gpg can be a bit daunting and you've not really given any detail about how you'd like to encrypt it other than with gpg.

You might want to look through the link here:
http://www.dewinter.com/gnupg_howto/...MiniHowto.html
 
2 members found this post helpful.
Old 01-16-2014, 10:32 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,960

Rep: Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693
Quote:
Originally Posted by rivelino90 View Post
create a script that takes as an argument the path of a text file and encrypts it with command gpg. the script should consider when the file doesn't exists
You need to show actual effort of your own...don't just post your homework questions and ask for a handout.
 
  


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




All times are GMT -5. The time now is 05:03 PM.

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