LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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
 
LinkBack Search this Thread
Old 04-06-2007, 04:45 AM   #1
Gins
Senior Member
 
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,638

Rep: Reputation: 46
Help understanding a script


If you have file named 'foo.txt' on your system and you want to encrypt it for personal use, the following command will do the job.
gpg -e -r Name foo.txt

The following is for the decryption of the file.
gpg --output foo.txt --decrypt foo.txt.gpg

If you want to encrypt and decrypt the file very often, the following script makes life easy for you. However, I can't fathom out the program.

1. Is it a scripting program?
2. Where is the shebang?

This may not be a scripting program.

Please look at the following site to know about the program. I copied from this site.
http://www.madboa.com/geek/gpg-quickstart/

----------------------------------------------------------------


# example Makefile for viewing/editing an encrypted file
GPGID = you@your.address
FILEPLAIN = foo.txt
FILECRYPT = $(FILEPLAIN).gpg

GPG = gpg
RM = /bin/rm -i
VI = vim

all:
@echo ""
@echo "usage:"
@echo ""
@echo "* make view -- to see $(FILEPLAIN)"
@echo "* make edit -- to edit $(FILEPLAIN)"
@echo ""

edit:
@umask 0077;\
$(GPG) --output $(FILEPLAIN) --decrypt $(FILECRYPT)
@$(VI) $(FILEPLAIN)
@umask 0077;\
$(GPG) --encrypt --recipient $(GPGID) $(FILEPLAIN)
@$(RM) $(FILEPLAIN)

view:
@umask 0077; $(GPG) --decrypt $(FILECRYPT) | less
 
Old 04-06-2007, 05:56 AM   #2
jschiwal
Moderator
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,263

Rep: Reputation: 562Reputation: 562Reputation: 562Reputation: 562Reputation: 562Reputation: 562
You might want to read through the "info make" manual. Make is usually used to build programs. It makes controlling the production of large projects containing many files easier.

Before the colon are the targets. After the colon are the prerequisites. They are the files that are used to produce the target.
Below are the commands to run to produce the targets. If the timestamp of the prerequisite is newer than the target, then make will run the rules to produce the target. Otherwise, nothing needs to be done.

You can run make like this: "make <target>" to produce a particular target.

Last edited by jschiwal; 04-06-2007 at 05:57 AM.
 
Old 04-06-2007, 07:10 AM   #3
Gins
Senior Member
 
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,638

Original Poster
Rep: Reputation: 46
Thanks jschiwal
So this is a script.
Where is the shebang?
Where can I read this manual?
 
Old 04-06-2007, 12:27 PM   #4
jschiwal
Moderator
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,263

Rep: Reputation: 562Reputation: 562Reputation: 562Reputation: 562Reputation: 562Reputation: 562
No, it isn't a script. It is a "make" configuration file. The make command uses "Makefile" as the default.

When you type "make edit", the commands below the "edit:" target are executed. This is a strange use for make because there are no prerequisites. You could simply write a bash script that uses the "select" command to select the option you want and then carry out the same commands.
 
Old 04-06-2007, 12:56 PM   #5
Gins
Senior Member
 
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,638

Original Poster
Rep: Reputation: 46
I don't know what a 'make' configure file is.
However, I know we use the commands 'make' and 'make install' after expanding tarball.



I wrote the commands 'make' and 'make edit'. There is nothing.

---------------------
[Nissanka@]$ make
make: *** No targets specified and no makefile found. Stop.
[Nissanka@]$ make edit
make: *** No rule to make target `edit'. Stop.
[Nissanka@]$ edit
bash: edit: command not found
[Nissanka@]$

[Nissanka@]$ Makefile
bash: Makefile: command not found
[Nissanka@]$

Last edited by Gins; 04-10-2007 at 02:53 AM.
 
Old 04-07-2007, 11:55 AM   #6
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,371

Rep: Reputation: Disabled
The stuff you posted is a makefile. Save it in a file called Makefile (or makefile) and then you'll be able to run, for example, "make edit". Edit: you should remove your IP address from your posts, you've even been told before to do this (it's for your own good).

Last edited by Nylex; 04-07-2007 at 12:54 PM.
 
Old 04-07-2007, 04:01 PM   #7
Gins
Senior Member
 
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,638

Original Poster
Rep: Reputation: 46
Thanks Nylex
Please tell me how to alter the IP address. I don't mind having some other figures or a funny name.
The command 'ifconfig' tells me the IP Address, Broadcast Address, etc.
 
Old 04-08-2007, 02:59 AM   #8
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,371

Rep: Reputation: Disabled
Edit your post and just remove your address.
 
Old 04-08-2007, 03:10 AM   #9
Gins
Senior Member
 
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,638

Original Poster
Rep: Reputation: 46
Thank you. I did it.
 
Old 04-10-2007, 02:15 AM   #10
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,627
Blog Entries: 10

Rep: Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776
no you didn't ... *sigh*
 
Old 04-10-2007, 02:54 AM   #11
Gins
Senior Member
 
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,638

Original Poster
Rep: Reputation: 46
Tinkster
I missed some of them. Now it is fine,
 
Old 04-12-2007, 02:13 AM   #12
jschiwal
Moderator
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,263

Rep: Reputation: 562Reputation: 562Reputation: 562Reputation: 562Reputation: 562Reputation: 562
Make sure that you cd to the directory that contains the Makefile. Otherwise, make won't be able to find it. Just to reiterate: A Makefile is a configuration file for the "make" command.

One thing I should mention if you are going to write or edit your makefile. The command lines need to begin with a tab. Those aren't spaces. Also, don't edit a makefile in windows can copy it to Linux. This is true for bash scripts as well.

IMHO, it would be better to create scripts and put them in your ~/bin/ directory then to use make. If ~/bin is in your PATH variable, you could run a script instead and not need to cd to a particular directory to run it.
A script could start with the lines:
FILEPLAIN = "${1}"
FILECRYPT = $(FILEPLAIN).gpg

Then you could use an argument for the file to encrypt instead of having it hardcoded in a Makefile.

Using make would make sense if you wanted to encrypt any unencryped files in a directory or handle files newer than a timestamp. The makefile could, for example, create a timestamped file (using the touch command) as the final step and use files in the directory as prerequisites. You could have a rule that encoded .txt files. Even then the make command to launch the process could be contained in a script.

But, this is just one persons opinion. To each their own. Anyway, you are learning about using make.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
help with understanding /ect/init.d/network script LDZ420 Linux - Newbie 2 05-19-2006 04:07 PM
Need help understanding script....? jmr0311 Mandriva 3 08-08-2004 07:42 AM
Startup script, help understanding it..? jmr0311 Linux - Software 1 08-07-2004 05:59 PM
Understanding X?? ++ bdp Linux - General 2 02-25-2004 05:47 PM
Understanding df -k itsjustme Linux - General 6 10-28-2003 12:08 PM


All times are GMT -5. The time now is 05:01 AM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration