How to make a command same as PICO in linux but with comments


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to make a command same as PICO in linux but with comments
# 1  
Old 03-06-2011
How to make a command same as PICO in linux but with comments

Hello, i need to make a linux command but i dont know how..
my proposal is to make a command same as pico but with comments..
for example if i enter picoc, it will run like pico but with this comments..
#==================================
#Script Name:
#By:
#Date:
#Purpose:
#:Command Line:
#====================================

help me thanks
# 2  
Old 03-08-2011
Well, you can write a wrapper shell script for it named pico, and the wrapper can compose the header. Rename pico to something like pico.original or put the wrapper in a up-$PATH directory from the current pico. I am assuming pic does not have an attitude about its name, examining argv[0].
# 3  
Old 03-08-2011
I'd avoid renaming pico or anything. If you really want to override pico itself, you could make it an alias like alias pico=/usr/local/sbin/picoc.sh But it sounds like he wants to just type it as picoc.

Code:
#!/bin/sh

# picoc.sh

for FILE in "$@"
do
        # Don't mangle files that already exist
        [ -e "$FILE" ] && continue

        cat <<EOF > "$FILE"
#==================================
#Script Name:
#By:
#Date:
#Purpose:
#:Command Line:
#==================================== 
EOF
done

exec pico "$@"

It goes through the list of arguments "$@", and for each file that doesn't exist, dumps the header into it.

This will cause some difference from normal pico behavior: It will create brand new files whether the pico user saves them or not. And it won't support commandline switches properly. To do that you'd have to brute-force parse each parameter one by one and decide what it means and whether it's a file the hard way -- by exacting the same as pico.

Last edited by Corona688; 03-08-2011 at 06:05 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Ed vs pico

Hello! Please, can someone make me clear the difference betveen and interactive and non-interactive test editor? (is not each editor somehow "interactive"???) Many thanks!!! (0 Replies)
Discussion started by: pinklemon
0 Replies

2. Shell Programming and Scripting

Problem with "make" command in Linux

Hi all, I downloaded an external program and extracted all the files to a folder. they have a make file which I have to run. But when I run make file I get an error g++ -O2 -c pgm.cpp make: g++: Command not found make: *** Error 127 When I checked the list of GCC I get this binf-01... (14 Replies)
Discussion started by: kaav06
14 Replies

3. Shell Programming and Scripting

Sed script, changing all C-comments to C++-comments

I must write a script to change all C++ like comments: // this is a comment to this one /* this is a comment */ How to do it by sed? With file: #include <cstdio> using namespace std; //one // two int main() { printf("Example"); // three }//four the result should be: (2 Replies)
Discussion started by: black_hawk
2 Replies

4. UNIX for Dummies Questions & Answers

pico vs vim

I always used pico as a text editor in Terminal or SSH. But what is the advantages/disadvantages between vim and pico? (7 Replies)
Discussion started by: timgolding
7 Replies

5. Shell Programming and Scripting

Script for updating the comments field on /etc/passwd on redhat linux

Hi there, I have more that 300 servers that I need to updated the comments field on /etc/passwd for users that have a blank comments fields. The users have accounts on different servers. I have created a list of these users on a text file called update_passwd.txt. I need a script that will... (6 Replies)
Discussion started by: Linux Duke
6 Replies

6. UNIX for Dummies Questions & Answers

Pico?

Is pico editor not availible on all versions of Unix? I do have vi and emacs, but pico just give me a response of "not found". (4 Replies)
Discussion started by: dereckbc
4 Replies

7. UNIX for Dummies Questions & Answers

question about pico?

Quick question for all of you Unix gurus. What are your thoughts on Pico as an editor. I have been using this editor for the last week or so and have made a lot of headway with my script writing. However, I find a lot of the quirks associated with this editor to be quite annoying. For instance,... (1 Reply)
Discussion started by: wmosley2
1 Replies

8. UNIX for Dummies Questions & Answers

pico text editor

I was wondering if there is any way to get a version of pico for windows. I have done a lot of programming work on Linux/UNIX exvironments for school, and I enjoy using pico for my programming needs, but I find all of the text editors in windows horrible, they distort my code and do not adhere to... (5 Replies)
Discussion started by: popac
5 Replies

9. UNIX for Dummies Questions & Answers

vi and pico

hello iam so new to unix / apache what is the dif between VI and PICO where can i get hands on training with both in Los Angeles any ideas would be helpfull. thanx whothought (5 Replies)
Discussion started by: whothought
5 Replies
Login or Register to Ask a Question