script that will take input via a vi session


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script that will take input via a vi session
# 1  
Old 08-12-2011
script that will take input via a vi session

Hi there.

I am trying to write a script that will be used to record actions. eg


Code:
 
# ./worklog -a "Peformed a memory upgrade on this box after we experiened a DIMM failure"


at which point the script will log to file called /var/worklog prepending the comment with the users name and date, with the most recent comments on top

eg

Code:
 
# cat /var/worklog
 
**2011-08-10  Peter Jones**
 
Peformed a memory upgrade on this box after we experiened a DIMM failure
------------------
 
**2011-08-09  John Smith**
 
Did some other stuff blah blah 
 
-------------------
...
...
...

Now this is all easy enough to do apart from when I want to get multiline blocks of text (eg pasting from an email) then command line falls over.

Is it possible for me to invoke a vi session from by say running a -v flag as opposed to a -a which will drop me into vi, i can paste what I want and the mere action of saving and quiting the session would take the input and process it as it would do if i entered the comment on the command line

Ive seen this done before for example on subversion when you do an 'svn commit' it opens a vi session and when you save/quit, it takes those comments.

Is this hard to code, I can tseem to find any info on how to do it ?

any help would be greatly appreciated
# 2  
Old 08-12-2011
???
Code:
tmp=`tempfile` # or tmp=/tmp/$0.$$
# add, append something to $tmp
vi "$tmp"
# do something with $tmp
rm "$tmp"

# 3  
Old 08-15-2011
thanks (i guess it was simpler that i originally thought Smilie)
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to delete files with an input for directories and an input for path/file

Hello, I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall: I regularly need to delete files from many directories. A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
Discussion started by: *ShadowCat*
3 Replies

2. Shell Programming and Scripting

running a script in a ftp session

Hi guys, I am using a script that run ftp and transfer file from my source server to the destination server. Since i have transferred my files to the destination server, now i want to run a script at the destination server. Could you please help me regarding how to run a script in a ftp... (7 Replies)
Discussion started by: jaituteja
7 Replies

3. Solaris

Difference between the desktop session and console session

what is the difference between desktop session and console session in solaris as i am wondering we use option -text for the former and -nowin for the later (1 Reply)
Discussion started by: kishanreddy
1 Replies

4. Shell Programming and Scripting

session timeout for shell script

I am executing test.sh script. But this script takes lot of time and in the meantime the shell timeouts without completing the script. Is there any command which will continue processing the script. Thanks (3 Replies)
Discussion started by: infyanurag
3 Replies

5. Solaris

I am not able to login in gnome session and java session in Sun solaris 9& 10

I am not able to login in gnome session and java session in Sun solaris 9& 10 respectively through xmanager as a nis user, I am able to login in common desktop , but gnome session its not allowing , when I have given login credentials, its coming back to login screen, what shoul I do to allow nis... (0 Replies)
Discussion started by: durgaprasadr13
0 Replies

6. Shell Programming and Scripting

Hiding Directories on a Session by Session basis

Hi, Apologies if anyone has read my recent post on the same subject in the Linux forum, just thought actually the solution might more likely come from scripting. Essentially, I am trying to restrict access to directories based on the user's name AND their location on a session-by-session... (3 Replies)
Discussion started by: en7smb
3 Replies

7. Shell Programming and Scripting

running script in ftp session

Dear Friends, I have this script CAP2_Launcher on suntest server. this script needs two input files in order to process them and produces an output files. I've created .bat file from windows to access the server and transfer the input files needed by the script and execute the script then pull... (3 Replies)
Discussion started by: sfaqih
3 Replies

8. Shell Programming and Scripting

Running a script without a terminal session

I'm trying to figure out how I can run a script "myScript.sh" in such a way that if my remote network connection gets disconnected, the script doesn't stop functioning. Right now I log in, run "./myScript.sh" and watch my output get pumped to a log file for about 10 hours. Only problem is that... (3 Replies)
Discussion started by: jjinno
3 Replies

9. Shell Programming and Scripting

sqlplus session being able to see unix variables session within a script

Hi there. How do I make the DB connection see the parameter variables passed to the unix script ? The code snippet below isn't working properly. sqlplus << EOF user1@db1/pass1 BEGIN PACKAGE1.perform_updates($1,$2,$3); END; EOF Thanks in advance, Abrahao. (2 Replies)
Discussion started by: 435 Gavea
2 Replies
Login or Register to Ask a Question