Shell Script


Well sometime you didn’t have XWindows server (dtlogin or citrix) installed in your server. Maybe is a performance things. Because that application suck your server cpu and memory. Hard.

There is workaround to cheat this. You have to export display from your server to your desktop.

1. Use your favorit telnet/ssh session (putty, mstelnet, secure crt) to connect to the server.
2. Open Xserver/Reflection/Xmanager (or other X-Windows Emulator)
3. Export display
tcsh => setenv DISPLAY 10.1.1.1:0.0
ksh/bash => DISPLAY=10.1.1.1:0.0;export DISPLAY
note: 10.1.1.1 is your desktop IP
4. Execute gui command. For example:
Veritas Enterprise Administrator (vea) -> /opt/VRTS/bin/vea
OSS-RC (ONE) -> /opt/ericsson/bin/nms_one

Sometimes, when you do shell scripting, you have to call another command that need manual input.
For example, you want to send email from the shell

# mail adiguna@domain.com
To: adiguna@domain.com
From: you@domain.com
Hello!
.
#

You need to type manually the three last lines to send email.

You might ask how to handle this without interaction.
That’s when “here” document comes handy.

You can re-write the script like this
# mail adiguna@domain.com << END
To:
adiguna@domain.com
From: you@adiguna@domain.com
Hello!
.
END

The syntax for here-document is like this:

command << KEYWORD
input1
input2
input3
KEYWORD

I usually use this for mail and Sybase query (isql). For example:

isql -Usa -SSYB -Ppassword -w2000<<-! | egrep -v affected > cgi3.txt
use omcdb
go
select convert(char(10),c.imap_name) as BSC,
convert(char(25),b.imap_name) as SiteName,
convert(char(25),a.imap_name) as CellName,
convert(char(20),a.imap_CGI) as CGI
from BSCCell a,
BSCBTSSiteManager b,
BSCNE c where a.fdn like b.fdn+’.%’ and a.fdn like c.fdn+’.%’  and b.fdn like c.fdn+’.%’
order by c.imap_name
go
quit
!

Or you can also automate your ftp like this :
ftp -in noc4web << end
user anonymous email
prompt off
ascii
mput *.*
bye
end