f_Delete()
{
if [ -z "$printer" ]; then
echo "\n\t Printer to be deleted"
return 1
else
for P in $printer; do
echo "Deleting printer $P..."
$BIN/lpadmin -x $P
done
return 0
fi
}
Not sure why you need the surrounding if-statement though
so that i could call the variable $printer...
will it effect my function in any way if i remove it?????
---------- Post updated at 12:19 ---------- Previous update was at 12:10 ----------
made adjustments as suggested, but its not deleting the three printers!!!!!!!
Code:
f_Delete()
{
if [ -z "$printer" ]; then
echo "\n\t Printer to be deleted"
return 1
else
for P in $printer; do
echo "\n\t Deleting printer $Printer !!!"
$BIN/lpadmin -x $P
done
return 0
fi
}
this is the errors!!!
Code:
+ echo 0117bd1 2201bl7 5001bl1
0117bd1 2201bl7 5001bl1
+ f_Delete
Deleting printer !!!
lpadmin: The printer or class was not found.
Deleting printer !!!
Deleting printer !!!
Why is not picking up my three printers and deleting them????
Variables in UNIX, as in most languages are case-sensitive.
Code:
$Printer
is not the same as
Code:
$printer
In any case...
This:
Code:
echo "\n\t Deleting printer $Printer !!!"
Should be
Code:
echo "\n\t Deleting printer $P !!!"
Can you show that the printers were not deleted?
The error you got is because one of the printers you are trying to delete doesn't exist.
A small change:
Code:
f_Delete()
{
if [ -z "$printer" ]; then
echo "\n\t Nothing to do!"
return 1
else
for P in $printer; do
echo "\n\t Deleting printer $P !!!"
$BIN/lpadmin -x $P 2> /dev/null
done
return 0
fi
}
Now to recreate the printers deleted!!!
My function to recreate the printers i have as follows:
Code:
f_Create()
{
if [ -z "$printer" ]; then
echo "\n\t $printer does not exists"
return 1
else
for P in $printer; do
echo "\n\t Adding printers !!!!"
echo "Enter Printer Name: \c"
read printer
echo "Enter IP Address : \c"
read ip
echo "Enter Location : \c"
read loc
echo "Enter Description : \c"
read desc
echo "Enter Filter : \c"
read filt
echo "Enter Port : \c"
read port
echo "Enter Driver : \c"
read driv
$BIN/lpadmin -p "$printer" -E -D "$desc" -L "$loc" -i /u1/cups/mac/"$filt"_fi
lter -v "$driv"://"$ip":"$port"
done
echo "\n\t Printer $printer created"
fi
}
The reason for so many variables, is because we have printers with different drivers, ports,descriptions,locations and filters.
or would it be possible to re-create just these three printers with the info we have in diffs.txt
Code:
device for 0117bd1: lpd://172.25.29.60:515
device for 2201bl7: socket://172.25.11.170:9100
device for 5001bl1: lpd://172.25.11.203:515
---------- Post updated at 15:46 ---------- Previous update was at 13:56 ----------
script is hanging during execution of create function
Code:
#!/bin/ksh
BIN=/usr/lbin/
LOCAL_FILE=`$BIN/lpstat -v > sun5-printers.txt`
REMOTE_FILE=`rsh sun8 /usr/lbin/lpstat -v > sun8-printers.txt`
#DIFF_FILE=/usr/local/bin/diffs.txt
awk 'BEGIN {while ( getline < "sun5-printers.txt") {arr[$0]++ } } { if (!($0 in a
rr ) ) { print } }' sun8-printers.txt > diffs.txt
for i in `cat diffs.txt`
do
printer="$(awk -F: '{ print $1 }' | cut -c 11-18 diffs.txt)"
echo $printer
done
#done < diffs.txt
#Amend,create or delete Printer
f_Delete()
{
if [ -z "$printer" ]; then
echo "\n\t Nothing to be deleted!"
return 1
else
for P in $printer; do
echo "\n\t Deleting printer $P !!!"
$BIN/lpadmin -x $P 2> /dev/null
done
return 0
fi
}
f_Create()
{
if [ -z "$printer" ]; then
echo "\n\t $printer does not exists"
return 1
else
for P in $printer; do
echo "\n\t Adding printers !!!!"
echo "Enter Printer Name: \c"
read printer
echo "Enter IP Address : \c"
read ip
echo "Enter Location : \c"
read loc
echo "Enter Description : \c"
read desc
echo "Enter Filter : \c"
read filt
echo "Enter Port : \c"
read port
echo "Enter Driver : \c"
read driv
$BIN/lpadmin -p "$printer" -E -D "$desc" -L "$loc" -i /u1/cups/mac/"$filt"_fi
lter -v "$driv"://"$ip":"$port"
done
echo "\n\t Printer $printer created"
fi
}
f_Delete
f_Create
Is there problem with syntax within my script..any help will do?????
Hi All,
I am running the below proc in unix by connecting through sqlplus and the procedure is completing successfully. But when i am trying to run through shell scripting by using function. I am getting the error as follows. Please guide me where I am going wrong.
#!/bin/sh
opera ()
{... (6 Replies)
Dear All,
I have script.
Dest=""
IFS='
'
for translation in $(echo $MY_MAP)
do
t1=$(echo $translation | cut -d"=" -f1)
t2=$(echo $translation | cut -d"=" -f2| cut -d"," -f1)
if
then
Dest=$UNX/$u_product_path/$u_study_path/$UNXTR/$t2
break;
... (4 Replies)
Hi
We use "tcsh" shell . We do the following steps manually:
> exec ssh-agent zsh
> python "heloo.py" (in the zsh shell)
I am trying to do the steps above from a shell script
This is what I have so far
echo "Executing "
exec ssh-agent zsh
python "hello.py"
exit 0
Problem is... (5 Replies)
I am using following code to connect to oracle database from solaris shell script. which will try thrice to connect the database ...at the 4rth atempt it will exir=t.
count=0
while ; do
sqlplus -s $usrname/$password@dbSID <<-EOF | tee $logfile
WHENEVER OSERROR EXIT 9;
WHENEVER SQLERROR... (4 Replies)
Hi Experts,
I have a shell script which used to take oracle database backup, which is scheduled in a tidal scheduling tool. however it is throwing an error while triggering the job and getting below error in the log file.
"Launcher Error: This is an internal function"
shell script is... (1 Reply)
Hi All,
Is there any way where we can run few commands with different shell in a shell script ?
Let's have an example below,
My first line in script reads below,
#!/bin/sh
However due to some limitation of "/bin/sh" shell I wanted to use "/bin/bash" while executing few... (9 Replies)
Hi,
We are moving from linux to AIX servers, and as a result testing our scripts on the new platform. When I run one of our scripts, I get the following error message:
./branchDataUpdate.sh: syntax error at line 21 : `(' unexpected
Following is an extract from the script:
......
........ (1 Reply)
Storage_Unit=`du -h /var/spool/cron/root|awk '{print $1}'|sed -e "s/^.*\(.\)$/\1/"`
If
then
Size=`du -h /var/spool/cron/root|awk '{print $1}'|sed 's/.\{1\}$//'`
for Size_rounded_number in $(printf %.0f $Size); do
ROUNDED_Size=$Size_rounded_number
done
if #setting a threshold of say... (1 Reply)
Hi,
i have a script which need to do behave differently when run as a startup process from init.d/ rc2.d script and when run manually from shell.
How do i distinguish whether my script is run by init process or by shell??
Will the command
/proc/$$/psinfo | grep "myscript" work well???... (2 Replies)