In any case the best is to put your code in a script and call the script in the good .profile
It might be better placed in the shells startup code, that is: ~/.kshrc or ~/.bashrc, depending on which shell thread-o/p is using. Unlike the .profile, which is run every time a user logs in, the rc-file is executed every time a shell instance is started. This will happen automatically whenever a terminal emulator, such as xterm, is started.
Is that literally what it said, and literally all it said?
Yes, that is.
Code:
./Savelog: cannot execute
Maybe I need to set environment variable? I don't know. I think first of all I should run the Script manually and then try to put it on start-up.
As I said I didn't have any .profile file, I create one manually on the root.
---------- Post updated at 07:00 AM ---------- Previous update was at 06:52 AM ----------
Quote:
Originally Posted by bakunin
It might be better placed in the shells startup code, that is: ~/.kshrc or ~/.bashrc, depending on which shell thread-o/p is using.
Thanks for your reply bakunin
But as I said the shell is sh shell not bash or ksh.
I condemn to use only and only sh shell!
ran01:/home/vbe $ ssh dany1
Password:
Last login: Fri Jun 7 11:19:54 2013 from ran01.c*i.et*
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
Enter DISPLAY =
gzip: /export/home/vbe/terminal-logs/*.log: No such file or directory
logfile is : /export/home/vbe/terminal-logs/2013-06-07_11:20:37.21176.log
usage: script [ -a ] [ typescript ] # So I corrected the script...
Connection to dany1 closed.
ran01:/home/vbe $ ssh dany1
Password:
Last login: Fri Jun 7 11:20:36 2013 from ran01.c*i.et*
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
Enter DISPLAY =
gzip: /export/home/vbe/terminal-logs/*.log: No such file or directory
logfile is : /export/home/vbe/terminal-logs/2013-06-07_11:27:51.26677.log
Script started, file is /export/home/vbe/terminal-logs/2013-06-07_11:27:51.26677.log
dany1:/export/home/vbe $ ll
sh: ll: not found
dany1:/export/home/vbe $ r alias
alias ll='ls -al'
dany1:/export/home/vbe $ ll
total 38
drwxr-xr-x 4 vbe sysdso 9 Jun 7 11:27 .
drwxr-xr-x 21 root root 21 Jun 10 2011 ..
-rwx------ 1 vbe sysdso 6651 May 27 14:06 .kshrc
-rw-r--r-- 1 vbe sysdso 725 Jun 7 11:20 .profile
-rw------- 1 vbe sysdso 3056 Jun 7 11:28 .sh_history
drwx------ 2 vbe sysdso 3 Jun 7 10:45 .ssh
-rw-r--r-- 1 vbe sysdso 50 Dec 7 2007 dsmerror.log
-rwx------ 1 vbe sysdso 419 Jun 7 11:26 script_shell
drwxr-xr-x 2 vbe sysdso 3 Jun 7 11:27 terminal-logs
dany1:/export/home/vbe $ tail .profile
then
echo " Enter DISPLAY = "
read DISPLAY
export DISPLAY
fi
alias -x ll='ls -al'
export PS1=`uname -n`':$PWD \$ '
printf "\033]0;$(hostname) \007"
exec $HOME/script_shell
dany1:/export/home/vbe $ exit
Script done, file is /export/home/vbe/terminal-logs/2013-06-07_11:27:51.26677.log
exiting ...
Connection to dany1 closed.
ran01:/home/vbe $
The what will follow I have an issue to solve sorry...
Here you are:
This is for the case you get to your host by ssh...
Code:
#----------------
dany1:/export/home/vbe $ ll term*
total 10
drwxr-xr-x 2 vbe sysdso 3 Jun 7 11:27 .
drwxr-xr-x 4 vbe sysdso 9 Jun 7 11:27 ..
-rw-r--r-- 1 vbe sysdso 1073 Jun 7 11:28 2013-06-07_11:27:51.26677.log
dany1:/export/home/vbe $ ll .ssh/environment; cat .ssh/environment;
-rwx------ 1 vbe sysdso 192 Jun 7 10:45 .ssh/environment
# Set up the shell environment:
TMOUT=0
# Set up the shell variables:
EDITOR=vi
#ENV=$HOME/.kshrc
ENV=$HOME/.profile
HISTFILE=$HOME/.sh_history
HISTSIZE=10000
dany1:/export/home/vbe $
dany1:/export/home/vbe $ ll script_shell ; cat script_shell
-rwx------ 1 vbe sysdso 419 Jun 7 11:26 script_shell
if [ -z "$UNDER_SCRIPT" ]; then
logdir=$HOME/terminal-logs
if [ ! -d $logdir ]; then
mkdir $logdir
fi
gzip -q $logdir/*.log
logfile=$logdir/$(date +%F_%T).$$.log
export UNDER_SCRIPT=$logfile
echo logfile is : $logfile
#read kyb
#script -f -q $logfile
script -a $logfile
echo " exiting ..."
sleep 1
exit
fi
dany1:/export/home/vbe $ cat term*/* # I am looking at your log content (hehe you see it works...)
Script started on Fri Jun 07 11:27:51 2013
dany1:/export/home/vbe $ ll
sh: ll: not found
dany1:/export/home/vbe $ r alias
alias ll='ls -al'
dany1:/export/home/vbe $ ll
total 38
drwxr-xr-x 4 vbe sysdso 9 Jun 7 11:27 .
drwxr-xr-x 21 root root 21 Jun 10 2011 ..
-rwx------ 1 vbe sysdso 6651 May 27 14:06 .kshrc
-rw-r--r-- 1 vbe sysdso 725 Jun 7 11:20 .profile
-rw------- 1 vbe sysdso 3056 Jun 7 11:28 .sh_history
drwx------ 2 vbe sysdso 3 Jun 7 10:45 .ssh
-rw-r--r-- 1 vbe sysdso 50 Dec 7 2007 dsmerror.log
-rwx------ 1 vbe sysdso 419 Jun 7 11:26 script_shell
drwxr-xr-x 2 vbe sysdso 3 Jun 7 11:27 terminal-logs
dany1:/export/home/vbe $ tail .profile
then
echo " Enter DISPLAY = "
read DISPLAY
export DISPLAY
fi
alias -x ll='ls -al'
export PS1=`uname -n`':$PWD \$ '
printf "\033]0;$(hostname) \007"
exec $HOME/script_shell
dany1:/export/home/vbe $ exit
script done on Fri Jun 07 11:28:43 2013
dany1:/export/home/vbe $
In other words if you telnet , remsh or rlogin, the append in .profile is enough, if you get to remote via ssh, you will have to create if you have no file environment as I show you above.
By X means to correct .dtprofile to make it read .profile:
bottom of .dtprofile:
Code:
# # login screen, login and correct the error. The $HOME/.dt/startlog and
# # $HOME/.dt/errorlog files may be helpful in identifying errors.
# #
# ##########################################################################
#
# If $HOME/.profile (.login) has been edited as described above, uncomment
# the following line.
#
DTSOURCEPROFILE=true
ADDENDUM:
Just read your last question: exec here I use exec since when the command script ends, the forked shell exits, and you find yourself at your login prompt... which I suspect is not what you want.
exec will make the forked shell, the current shell that will at exit end the session... as you can see on my first code trace above
Last edited by vbe; 06-07-2013 at 07:13 AM..
Reason: ADDENDUM
But as I said the shell is sh shell not bash or ksh.
You said you use "sh shell". This can mean one of two things: a POSIX shell or a Bourne Shell. If it is a POSIX shell you can set the variable "ENV" pointing to some startup file. This would be called every time a new shell starts. If it is a Bourne Shell, then you can use the startup option of the terminal: in case of "xterm" use the "-e" option to specify a program to be run at terminal startup.
when I run C:\cygwin\bin\run C:\cygwin\bin\startxwin.exe it fires up a terminal by default. Can I eliminate that terminal and start the x server as a service silently and sits in my status bar just there? Thanks Jack (0 Replies)
Hello.
Normally when you double click on the file name, the shell script start in background.
If you want to see what is going on, you must open a terminal console and start the shell within the terminal.
Is it possible to start directly a shell script in a terminal console from the file... (0 Replies)
Hello Guys
Please let me know how to solve the below issue
I have a file like below
drop table R1416.ABC1 cascade constraints;
drop table R1416.ABC2 cascade constraints;
drop table R1416.ABC3 cascade constraints;
drop table R1416.ABC4 cascade constraints;
drop table R1416.ABC5... (7 Replies)
Hello sir,
I want to monitor my work on the terminal.I know we can use script command.But every time when I start the terminal, I have to type script to start it.I want to automate it. So where should I include this command so that it will start as soon as I start the terminal ???? (2 Replies)
Hi all,
I am trying to write a script that launch the cisco vpn client from the command line and then connects to a remote host using ssh.
When i connect to the cisco vpn using vpnclient client connect the last lines of output from that client is
Encryption: 168-bit 3-DES
Authentication:... (0 Replies)
I have put the file descriptor 1 to file, using command exec 1>>out.txt
Then I could not see any output on the screen, how could I restore the default output to terminal? :mad: Thanks (3 Replies)
Hi everyone,
I'm pretty new using UNIX, but a friend of mine was helping me configure the unix terminal on my mac, and he changed some stuff on the bash profile .bash_profile. Everything was going well until I shut my computer and restarted it. When I opened the terminal this time this is what... (1 Reply)
hi
i want to know the way by which i put any file somewhere and it get s started when the system restarts or bots
i mean whenever my system starts that application must also start
thanks (3 Replies)
Hi,
How do I "run a script"?
I'm trying to start up some software called ElectroServer 3, and was told I just needed to "run the start script from the terminal to get things going".
From the terminal, i use cd command to change to the software's directory, and I guess the script in question is... (4 Replies)