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!

Perl Script to launch "smit print" Screens

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;
}}}}}
 
My first thought is that when perl is ran, the process is not associated with a tty when calling smit. You could run the tty commmand (works on solaris, didn't test on AIX yet). You will see similar problems while running the passwd command with most scripts.
As a seperate approach you could use expect, login to smit and enter interact mode so the user can do what they need, the on the termination command, return the user back to the menu.
 
Hi jtombre,

Thanks for the reply. I am able to get into the smit screens now using the tty when calling smit. Could you explain the part of the temination command that returns the user back 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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top