Put Script on Start-up the sh Terminal


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Put Script on Start-up the sh Terminal
# 1  
Old 06-06-2013
Put Script on Start-up the sh Terminal

Hi all
I want to put this script on start-up the sh Terminal to save history of output:
Code:
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
        script -f -q $logfile
        exit
fi

But I can't find how to do that. I should only use the sh shell. yes in bash shell there is some way, but how about sh?
I alter the files profile .dtprofile and I create .profile on root directory and changed all of them and add this codes:
Code:
 echo Rahim
ls -a
Rahim=123
echo $Rahim

But any of them didn't work.
Is it possible to put Script on start-up the Terminal to execute every time that a Terminal starts? If possible please let me know.
I use x86 sun Solaris 10.

Thanks for your helps.

Last edited by vbe; 06-06-2013 at 10:00 AM..
# 2  
Old 06-06-2013
Q.1:
How do you connect?

If you connect via a Xserver ( emulator like Rx or Hummingbird...), and use ssh, do you know which profile is being used?... (Look at the man pages of ssh...)
This User Gave Thanks to vbe For This Post:
# 3  
Old 06-06-2013
Are you talking of local on a workstation ?

In any case the best is to put your code in a script and call the script in the good .profile using exec otherwise you will find yourself with the prompt waiting yet another exit since script forks a new shell...
This User Gave Thanks to vbe For This Post:
# 4  
Old 06-06-2013
Now it is on my virtual box and it is local. But on the office I connect Using Xserver.
Sometime we use telnet, But that's not so important. When we connect from Xserver to desktop of the Solaris I need to do that. I can't find the .profile file in home, then I create one but nothing! I think echo command maybe not worked.
then you said to me I should call my Script with the exec command on .profile?
OK let me try.
Thanks for your help.
# 5  
Old 06-06-2013
There is an importance: using telnet you will read .profile, using ssh you will not unless you create a environment file in .ssh directory specifying so...
I tested at work your bit of script : put in a script and called the script in .profile... works as expected :
Even though you put an exit at the end and I added an extra as last line of .profile when I type exit I found myself at the prompt so:
You must use my previous syntax using exec
I tested... works great...
# 6  
Old 06-06-2013
But not for me!
I am so new on this. I should try. but another question?
Where is the .profile location? I didn't have any! I create one in the / directory. Am I right?

---------- Post updated at 11:54 PM ---------- Previous update was at 11:43 PM ----------

It give me the error cannot execute
I exec it directly from Terminal with this
Code:
./Savelog

this was the second question! Am I right?
# 7  
Old 06-06-2013
Quote:
Originally Posted by Rahim_T
It give me the error cannot execute
Is that literally what it said, and literally all it said?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

Start X Server without starting a terminal

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)
Discussion started by: lucky7456969
0 Replies

2. Shell Programming and Scripting

How to start a shell script in a terminal console from graphic environment?

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)
Discussion started by: jcdole
0 Replies

3. Shell Programming and Scripting

Put a # in start of a specific line of a file

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)
Discussion started by: Pratik4891
7 Replies

4. Shell Programming and Scripting

how to start SCRIPT command at begin of TERMINAL?

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)
Discussion started by: nsharath
2 Replies

5. IP Networking

start a new terminal from a script after opening VPN

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)
Discussion started by: borderblaster
0 Replies

6. UNIX for Dummies Questions & Answers

How to put the STDOUT back to terminal

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)
Discussion started by: biglau
3 Replies

7. UNIX for Dummies Questions & Answers

Terminal doesnt start

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)
Discussion started by: thefloydpink
1 Replies

8. Linux

where to put an application if i want to start it on start up

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)
Discussion started by: shukla_chanchal
3 Replies

9. UNIX for Dummies Questions & Answers

Run the start script from the terminal? Newbie Time!

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)
Discussion started by: waking_bear
4 Replies
Login or Register to Ask a Question