tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* Summary: trying to get a script to change directories....
@ 2001-04-18 19:28 George Gallen
  0 siblings, 0 replies; only message in thread
From: George Gallen @ 2001-04-18 19:28 UTC (permalink / raw)
  To: tru64-unix-managers

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: multipart/mixed; boundary="------_=_NextPart_001_01C0C83D.B4D56B50", Size: 7690 bytes --]

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C0C83D.B4D56B50
Content-Type: text/plain;
	charset="iso-8859-1"

At least I wasn't going crazy (well...I take that back).
 
Two options:
 
1. Create a symlink for current (I'm running an older OS that doesn't have
it)
2. use the "." command
 
so typing ". myscript" works
 
from Paul Sand, see the following URL:
 <http://www.faqs.org/faqs/unix-faq/faq/part2/section-8.html>
http://www.faqs.org/faqs/unix-faq/faq/part2/section-8.html

 

and from Alan Davis:

Newer versions of the OS include the "current" link. To simulate this in
older releases I modifed /sbin/init.d/syslog to do it for me :

 
case "$1" in'start')
set `who -r`
if [ $9 = "S" ]; then
if /usr/sbin/syslogd; then
echo "System error logger started"
rm /var/adm/syslog.dated/current
ln -s /var/adm/syslog.dated/`ls -ct /var/adm/syslog.dated | head -1`
/var/adm/syslog.dated/current
else
echo "Cannot start system error logger"
fi
fi
;;
 
 
Thanks to all who responded. Both the above methods are working.
 
George
 

-----Original Message-----
From: George Gallen [mailto:ggallen@slackinc.com]
Sent: Wednesday, April 18, 2001 3:01 PM
To: 'tru64-unix-managers@ornl.gov'
Subject: trying to get a script to change directories....



What I'm doing is I want to execute a script which will cd me 
to the latest syslog files. 

I'm using the following: 

cd /var/adm/syslog.dated/`ls -t /var/adm/syslog.dated | head -n 1` 

If I type it directly, it works, however if I run it as a script, I'm sure 
the script pid changes directories, but when it ends, I'm back where 
I was. 

How do I run the script without forking off a new PID? 

Thanks 
George 


George Gallen 
Senior Programmer/Analyst 
Accounting/Data Division 
ggallen@slackinc.com 
ph:856.848.1000 Ext 220 

SLACK Incorporated - An innovative information, education and management
company 
http://www.slackinc.com <http://www.slackinc.com>  


------_=_NextPart_001_01C0C83D.B4D56B50
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<TITLE>trying to get a script to change directories....</TITLE>

<META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR></HEAD>
<BODY>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN =
class=3D310532419-18042001>At=20
least I wasn't going crazy (well...I take that =
back).</SPAN></FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
class=3D310532419-18042001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN =
class=3D310532419-18042001>Two=20
options:</SPAN></FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
class=3D310532419-18042001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN =
class=3D310532419-18042001>1.=20
Create a symlink for current (I'm running an older OS that doesn't have =

it)</SPAN></FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN =
class=3D310532419-18042001>2. use=20
the "." command</SPAN></FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
class=3D310532419-18042001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN =
class=3D310532419-18042001>so=20
typing ". myscript" works</SPAN></FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
class=3D310532419-18042001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN =
class=3D310532419-18042001>from=20
Paul Sand, see the following URL:</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff><SPAN class=3D310532419-18042001><A=20
href=3D"http://www.faqs.org/faqs/unix-faq/faq/part2/section-8.html"><FON=
T=20
face=3DArial=20
size=3D2>http://www.faqs.org/faqs/unix-faq/faq/part2/section-8.html</FON=
T></A></DIV>
<DIV>
<P><FONT face=3DArial size=3D2></FONT>&nbsp;</P>
<P><SPAN class=3D310532419-18042001><FONT face=3DArial size=3D2>and =
from Alan=20
Davis:</FONT></SPAN></P>
<P><SPAN class=3D310532419-18042001></SPAN><SPAN =
class=3D310532419-18042001><FONT=20
face=3D"Courier New" color=3D#0000ff size=3D2><SPAN =
class=3D451275618-18042001>Newer=20
versions of the OS include the "current" link. To simulate this in =
older=20
releases I modifed /sbin/init.d/syslog to do it for me =
:</SPAN></FONT></P>
<DIV><FONT face=3D"Courier New" color=3D#0000ff size=3D2><SPAN=20
class=3D451275618-18042001></SPAN></FONT>&nbsp;</DIV><SPAN=20
class=3D451275618-18042001><PRE>case "$1" in'start')</PRE><PRE>set `who =
-r`</PRE><PRE>if [ $9 =3D "S" ]; then</PRE><PRE>if /usr/sbin/syslogd; =
then</PRE><PRE>echo "System error logger started"</PRE><PRE>rm =
/var/adm/syslog.dated/current</PRE><PRE>ln -s /var/adm/syslog.dated/`ls =
-ct /var/adm/syslog.dated | head -1` =
/var/adm/syslog.dated/current</PRE><PRE>else</PRE><PRE>echo "Cannot =
start system error =
logger"</PRE><PRE>fi</PRE><PRE>fi</PRE><PRE>;;</PRE><PRE>&nbsp;</PRE><PR=
E>&nbsp;</PRE><PRE>Thanks to all who responded. Both the above methods =
are =
working.</PRE><PRE>&nbsp;</PRE><PRE>George</PRE><PRE>&nbsp;</PRE></SPAN>=
</SPAN></SPAN></FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px =
solid; MARGIN-RIGHT: 0px">
  <DIV class=3DOutlookMessageHeader><FONT face=3D"Times New Roman"=20
  size=3D2>-----Original Message-----<BR><B>From:</B> George Gallen=20
  [mailto:ggallen@slackinc.com]<BR><B>Sent:</B> Wednesday, April 18, =
2001 3:01=20
  PM<BR><B>To:</B> 'tru64-unix-managers@ornl.gov'<BR><B>Subject:</B> =
trying to=20
  get a script to change directories....<BR><BR></FONT></DIV>
  <P><FONT face=3DArial size=3D2>What I'm doing is I want to execute a =
script which=20
  will cd me</FONT> <BR><FONT face=3DArial size=3D2>to the latest =
syslog=20
  files.</FONT> </P>
  <P><FONT face=3DArial size=3D2>I'm using the following:</FONT> </P>
  <P><FONT face=3DArial size=3D2>cd /var/adm/syslog.dated/`ls -t=20
  /var/adm/syslog.dated | head -n 1` </FONT></P>
  <P><FONT face=3DArial size=3D2>If I type it directly, it works, =
however if I run=20
  it as a script, I'm sure</FONT> <BR><FONT face=3DArial size=3D2>the =
script pid=20
  changes directories, but when it ends, I'm back where</FONT> =
<BR><FONT=20
  face=3DArial size=3D2>I was.</FONT> </P>
  <P><FONT face=3DArial size=3D2>How do I run the script without =
forking off a new=20
  PID?</FONT> </P>
  <P><FONT face=3DArial size=3D2>Thanks</FONT> <BR><FONT face=3DArial=20
  size=3D2>George</FONT> </P><BR>
  <P><B><FONT face=3D"Times New Roman" color=3D#800000 size=3D2>George=20
  Gallen</FONT></B> <BR><FONT face=3D"Times New Roman" color=3D#800000 =
size=3D2>Senior=20
  Programmer/Analyst</FONT> <BR><FONT face=3D"Times New Roman" =
color=3D#800000=20
  size=3D2>Accounting/Data Division</FONT> <BR><FONT face=3D"Times New =
Roman"=20
  color=3D#800000 size=3D2>ggallen@slackinc.com</FONT> <BR><FONT=20
  face=3D"Times New Roman" color=3D#800000 size=3D2>ph:856.848.1000 Ext =
220</FONT>=20
</P>
  <P><B><FONT face=3D"Times New Roman" color=3D#800000 size=3D2>SLACK=20
  Incorporated</FONT></B><FONT face=3D"Times New Roman" color=3D#800000 =
size=3D2> -<I>=20
  An innovative information, education and management =
company</I></FONT>=20
  <BR><U><FONT face=3D"Times New Roman" color=3D#0000ff size=3D2><A =
target=3D_blank=20
  =
href=3D"http://www.slackinc.com">http://www.slackinc.com</A></FONT></U> =

</P></BLOCKQUOTE></BODY></HTML>

------_=_NextPart_001_01C0C83D.B4D56B50--

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-04-18 19:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-04-18 19:28 Summary: trying to get a script to change directories George Gallen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox