Sponsored Content
Full Discussion: Problem with PATH
Top Forums Shell Programming and Scripting Problem with PATH Post 303020751 by wbport on Thursday 26th of July 2018 04:50:33 PM
Old 07-26-2018
Problem with PATH

Recently I lost a number of changes I made to a program when the SCO Unix system went down. The system "mail" suggested a "vi -r" option that took me back several days. To prevent this in the future, I am trying to create my own vi command:
Code:
if [ $# -eq 1 ]
  then
  cp -p $1 $1.bak
fi
/usr/bin/vi $*
if [ $# -eq 1 ]
  then
  rm $1.bak
fi

I put this in my home directory where my PATH in ".profile" is
Code:
PATH=.:/usr/shells:/bin:/etc:/usr/bin:/tcb/bin:/u/wbport

When looking at my home directory from another login, I don't see the .bak file. What am I missing?

------ Post updated at 03:50 PM ------

I could use it after logging off and then back on. If this looks like it would be useful, change the first if to
Code:
if [ $# -eq 1 -a -s $1 ]

If the file doesn't exist yet, there is nothing to back up.

The last if statement should be the same as the first one or just check for the presence of $1.bak .
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

PATH variable problem

root->echo $PATH /usr/ccs/bin:/opt/sfw/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin root->find / -name gcc /usr/local/bin/gcc /usr/local/doc/gcc root->which gcc no gcc in /usr/sbin /usr/bin Why cant it find gcc - the path looks okay doesnt it? I am running solaris 9 - and... (7 Replies)
Discussion started by: frustrated1
7 Replies

2. UNIX for Dummies Questions & Answers

cc path problem - no acceptable path found

Hello everyone, I'm a unix noob. I have a powerbook running mac os x 10.4 and for one of my classes I need to install the latest version of php (5.0.5). I'm following the instructions at http://developer.apple.com/internet/opensource/php.html to install but I've run into a problem. The... (2 Replies)
Discussion started by: kendokendokendo
2 Replies

3. Shell Programming and Scripting

path problem

hi , i have written csh script i am unable to set PATH variable in my script. my script is like this ===================================== # ! /bin/csh -f setenv PATH "$PATH:/opt/terascan/bin" ls -l > list lspass > pas peekauto > schedule \ num_days = 1 \ exit 0... (1 Reply)
Discussion started by: rajan_ka1
1 Replies

4. UNIX for Advanced & Expert Users

path problem

Hi i am writing a script containing processing commands which are reside in /opt/terascan/bin dir. if i run the script from command prompt it is working fine. but in crontab it is not working. if i give env command from command prompt it is showing /opt/terascan/bin dir in PATH variable. ... (10 Replies)
Discussion started by: rajan_ka1
10 Replies

5. Shell Programming and Scripting

Problem with File path

How to pass a file path to open a file? I am using cygwin. I want to open a file from a particular path, say C:\Test\File1,. This file path is stored in a variable. I am able to cat a file like this : cat "c:\Test\File1" but i want the same thing to happen in my script file through a variable... (3 Replies)
Discussion started by: sandeep_hi
3 Replies

6. Solaris

Problem Setting $PATH

I am trying to install the pkg-get package to a fresh install of Solaris 10. I am able to download and install correctly using the default directory for both pkg-get and wget as found on blastwave.org. When I issue the command "which wget and which pkg-get" it returns no wget or pkg-get found in... (1 Reply)
Discussion started by: greengrass
1 Replies

7. Infrastructure Monitoring

Problem with PATH

On one of the machines at work, we had Net-SNMP 5.2.3 installed, and I wanted to upgrade that to 5.4.2.1. So I downloaded the tar file, extracted it, did the configure, make, make test, make install, and everything worked. All the executable files (like snmpget, snmpset, snmpwalk) got copied to... (1 Reply)
Discussion started by: sllinux
1 Replies

8. Shell Programming and Scripting

if PATH contains a certain string problem!

Hi I am using MKS Toolkit c shell. I want to basically check if my PATH variable already contains a certain path directory so I tried this (it didnt work!): if: Expression Syntax if ( echo $path |grep -c c:/PROGRA~1/blah/blah ) then please help me get this little statement to work. ... (3 Replies)
Discussion started by: vas28r13
3 Replies

9. Shell Programming and Scripting

Problem with spaces in the path

Hi all, I have a variable test has the following value assigned.. could you please help on doing cd or ls to the value in the varible ... $echo $test /bdm/sdd/compounds/AD4833XT/requests/clin/Watson_20090420/docs/MHRA\ Comments\ \&\ Responses $cd $test ksh: cd: bad argument count $cd... (3 Replies)
Discussion started by: firestar
3 Replies

10. UNIX for Beginners Questions & Answers

PATH problem

For the sake of not going insane and not buggering a load of needed system stuff, I have created a dir /mybin. (This is a Debian system.) I have then edited the /etc/profile and /etc/login.defs files and added :/mybin to all of the path variables. I have the file /mybin/mtp for... (2 Replies)
Discussion started by: MuntyScrunt
2 Replies
MSGS(1) 						    BSD General Commands Manual 						   MSGS(1)

NAME
msgs -- system messages and junk mail program SYNOPSIS
msgs [-fhlpq] [number] [-number] msgs [-s] msgs [-c] [-days] DESCRIPTION
The msgs utility is used to read system messages. These messages are sent by mailing to the login `msgs' and should be short pieces of information which are suitable to be read once by most users of the system. The msgs utility is normally invoked each time you login, by placing it in the file .login (or .profile if you use sh(1)). It will then prompt you with the source and subject of each new message. If there is no subject line, the first few non-blank lines of the message will be displayed. If there is more to the message, you will be told how long it is and asked whether you wish to see the rest of the message. The possible responses are: -y Type the rest of the message. RETURN Synonym for y. -n Skip this message and go on to the next message. - Redisplay the last message. -q Drop out of msgs; the next time msgs will pick up where it last left off. -s Append the current message to the file ``Messages'' in the current directory; `s-' will save the previously displayed message. A `s' or `s-' may be followed by a space and a file name to receive the message replacing the default ``Messages''. -m A copy of the specified message is placed in a temporary mailbox and mail(1) is invoked on that mailbox. Both `m' and `s' accept a numeric argument in place of the `-'. The msgs utility keeps track of the next message you will see by a number in the file .msgsrc in your home directory. In the directory /var/msgs it keeps a set of files whose names are the (sequential) numbers of the messages they represent. The file /var/msgs/bounds shows the low and high number of the messages in the directory so that msgs can quickly determine if there are no messages for you. If the con- tents of bounds is incorrect it can be fixed by removing it; msgs will make a new bounds file the next time it is run with the -s option. If msgs is run with any option other than -s, an error will be displayed if /var/msgs/bounds does not exist. The -s option is used for setting up the posting of messages. The line msgs: "| /usr/bin/msgs -s" should be included in /etc/mail/aliases (see newaliases(1)) to enable posting of messages. The -c option is used for performing cleanup on /var/msgs. A shell script entry to run msgs with the -c option should be placed in /etc/periodic/daily (see periodic(8)) to run every night. This will remove all messages over 21 days old. A different expiration may be specified on the command line to override the default. You must be the superuser to use this option. Options when reading messages include: -f Do not say ``No new messages.''. This is useful in a .login file since this is often the case here. -q Queries whether there are messages, printing ``There are new messages.'' if there are. The command ``msgs -q'' is often used in login scripts. -h Print the first part of messages only. -l Cause only locally originated messages to be reported. num A message number can be given on the command line, causing msgs to start at the specified message rather than at the next message indicated by your .msgsrc file. Thus msgs -h 1 prints the first part of all messages. -number Start number messages back from the one indicated in the .msgsrc file, useful for reviews of recent messages. -p Pipe long messages through more(1). Within msgs you can also go to any specific message by typing its number when msgs requests input as to what to do. ENVIRONMENT
The msgs utility uses the HOME and TERM environment variables for the default home directory and terminal type. FILES
/var/msgs/* database ~/.msgsrc number of next message to be presented SEE ALSO
mail(1), more(1), aliases(5), periodic(8) HISTORY
The msgs command appeared in 3.0BSD. BSD
April 28, 1995 BSD
All times are GMT -4. The time now is 04:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy