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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to launch SMIT

Status
Not open for further replies.

bigkid123

ISP
Nov 5, 2002
18
US
I need to write a script that would launch certain Support Consoles with SMIT for our Support Staff. Currently they have command line access but we are considering taking this option away from them. We would like to be able to launch smit from our current menu screen and allow them the ability to access the "smit print" screens. We are using AIX 4.2.1. Any help would be appreciated that could help to generate a script that would allow this. Thanks in advance for your help
 
Here is the code of a script that I have created but when I try to access the options from the menu I receive this error "1800-003 No tty on stdout; SMIT needs a terminal for normal interactive
use. Use the -f flag to redirect stdin or stdout."

Not sure what I would need to change in the script to make it funtion properly. Any help would be appreciated.

#!/usr/local/bin/perl -w

$err_msg="Operation Failed Contact Help Desk";
$cl=system("clear");
$menu=<<'printq_menu';

Print Queue Reset Menu

1) Manage Print Jobs

2) Manage Print Queues

3) Print Queue Status

4) Exit
printq_menu
print $menu;
while($option = (<>))
{
#print $menu;
if($option=~/1/){
print &quot;\nManage Print JObs\n&quot;;
`smit jobs`;

#else{
if($? > 0){
print $err_msg;
exit;

}}
else{
if($option=~/2/){
print &quot;\nManage Print Queues\n&quot;;
`smit pqmanage`;
print $menu;
#else{

if($? > 0){
print $err_msg;
exit;
}}
else{
if($option=~/3/){
print &quot;\nStatus of Print Queues\n&quot;;
`lpstat`;
#else{
if($? > 0){
print $err_msg;
exit;
}}
else{
if($option=~/4/){
exit;
}}}}}

 
I was able to get this to work

You have to specify the sdout since you are not running smit directly from a terminal.


#!/usr/local/bin/perl -w

$err_msg=&quot;Operation Failed Contact Help Desk&quot;;
$cl=system(&quot;clear&quot;);
$tty=`who am i | cut -c 13-18`;
$menu=<<'printq_menu';

Print Queue Reset Menu

1) Manage Print Jobs

2) Manage Print Queues

3) Print Queue Status

4) Exit
printq_menu
print $menu;
while($option = (<>))
{
#print $menu;
if($option=~/1/){
print &quot;\nManage Print JObs\n&quot;;
`smit -f jobs > /dev/$tty`;

Hope this helps
Micheal
 
Thanks Micheal,

That did help, the only problem that I have now is that when you select the option to exit it just sits there and I have to manually bread out of it. Could you tell me what I would need to add to where when you chose to exit that it would return you to the menu.

Thanks
Daniel
 
I got it. just had to add two lines to my option system(&quot;clear&quot;); print $menu; and it worked thanks for your help though for everything else.
 
You could also have made a new Role and disallow the smit options, this way you have full control of smitty options they can use, plus, no programming involved. Here's a sample:

* Role NAME newadmins
AUTHORIZATIONS [PasswdAdmin]
Role LIST [ManageAllPasswds]
GROUPS [security]
Smit SCREENS [*,!install,!dev> (this is where its done)
VISIBILITY [1]
Message CATALOG []
Message NUMBER []
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top