ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,638
Rep:
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.
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.
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.
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,638
Original Poster
Rep:
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@]$
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).
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,638
Original Poster
Rep:
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.