Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unix scripting

Status
Not open for further replies.

likedoinit

Technical User
Oct 29, 2002
7
US
ok, i'm new at Solaris 8. I'm taking a class at ECPI right now. I have asked my instructor a question that he has never come across, and no one else has either.

What I want to do is when boot up into the cde, I want a console window to pop up and execute some form of command. IE: when the console window pops up it then executes the date command. It was just supposed to be something easy, but when the console window pops up, its now a different shell and the commands I want to be executed don't execute until i close the console window.

If i open up a term window and type dtterm -C I can get the console window to come up. How do i get that window now to execute the date command or any other command? They don't want to follow over to the new window. I thought i could redirect it but that doesn't seem to work. I was typing dtterm -C > date .

What brought this idea up was my instructor had said he made a script that will go and check if his back up ran successfully, and all the tmp files were deleted after backup. He has to type that scripts name to run it, and i was like how come you can make it run in a console window evertime you log in in the morning?

So i was trying to make a script that did that, and i was going to put it in the .profile or the .dtprofile so everytime he or whoever logs in, that console window will pop up and run those commands without me having to type them.

Any help would be really appreciated.

thanks
 
Use dtterm (or xterm) with the -e option. For example:

dtterm -e ls -al /tmp

The -e must be the last option for dtterm since everything after it is considered the command (and arguments) to execute. In the example, the -al is an ls option, not a dtterm option.

A caveat when using it this way is that once the command finishes, the dtterm window will close. If you do a 'date' command, it'll happen so fast you may not even see the window. One solution is to create a short script that runs the desired command and then does a sleep or waits for a keypress. Use that script as the command after the -e.

 
Dude you are awesome!!! that works like a champ. I was able to wirte a small script and have it execute it and have the sleep command at the end so i could see everything. Works great. What would the command be to wait for a keystroke?

thanks
 
ok, one more thing. I created a small script that has the date command and the ls -l and then sleep 20 in it. when i type in the terminal: dtterm -e ./script

the script opens up a new term window and the does the date and ls -l great. it sleeps for a few secs the closes. now that part works fine.

i tried to edit the .dtprofile and put in there: dtterm -e ./script and when i log back into the cde, nothing happens. i've also tried the .profile, local.profile and .kshrc and i can't get them to execute the dtterm -e ./script

it works fine from the term window but i want that to execute when i log into the cde. can ya help me out one more time? LOL.

Thanks again.
 
which session are you going into in cde?
if you always go into the 'home' session rather than the last one you were in, you can modify ~/.dt/sessions/home/dt.session and place the window stuff in there.
 
You may not have the path set up properly when you login. Try using a fully qualified path to start dtterm in the .profile.

Reading just any key is a little hard, but the enter key is easy. How to do it depends on which shell you use. Try this:

echo "Press enter to close this window..."
read var
 
ok i've been trying to play with this for the past few days. my home dir is: /export/home/user1 . now the script i wrote is:
#!/bin/ksh
echo "Hello"
date
ls -l
sleep 20

now i've made that script executable and i can type in the term window: dtterm -e ./script and a new term window pops up and runs the script fine.

I've tried to edit the .profile, .dtprofile, local.login and the Xsession by puttin in this:
dtterm -e /export/home/user1 script

this still isn't working when i log out and log back in. what file should i edit and am i typing in the right command?

thanks again.
 
Try this, in the .profile, put

/usr/dt/bin/dtterm -e /export/home/user1 script
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top