Thanks for all the input. Adding this line of code by tsuji really helped and solved the problem!
return undef unless defined $text;
I'm no longer getting this warning message -
"Use of uninitialized value in transliteration (tr///)
I've should've of provided more code. I already initialized the variable. Like so ..
sub check_address {
my $text = shift;
# There should only be 1 colon
my $count = $text =~ tr/://;
return undef if $count != 1;
# There should only be three .s
$count = $text =~ tr/.//;
return...
Hello everyone,
I keep getting this message every so often when my perl script runs. Any one have any ideas how to fix it? The message points to this particular code in my script.
Use of uninitialized value in transliteration (tr///)
my $count = $text =~ tr/://;
Thanks!
when I ran this script with the following changes .. I get this output
en1
found=Y
I can't get it to NOT print the "found=Y" statement. I tried to put a 'break' after the found="Y" but it still echos the found="N"
----------------------------------------
found="N"
for iface in `ifconfig -lu`...
sorry dkyrtata ..here's your original script .. I think there is confusion ..
the output of the script is right if there are no active interfaces found. The issue here is when it does find an active interfaces, it executes both statements ..printing
like so .. no matter what I do to modify it...
# here is the script that dkyrtata provided to me
found="N"
for iface in `ifconfig -lu` ; do
if [[ "$iface" != lo* ]]; then
ifconfig $iface | grep -q 'inet ' && echo $iface
found="Y"
done
fi
if [ "$found"=="N" ] ; then
echo "???"
fi
# below is my changes to try...
whether 'found' is upper or lower case ..the script executes the same ..i made lower case and it still produces the same result ..both statements are written when an active interface is found .. like so ..which is not the desired results
en1
No active interfaces found
I already tried that. still produces the same result. I tried putting an 'exit' block after it finds the interface so that it doesn't go to the next line of code "No active interfaces found" but it if I do that, this never gets checked
if [ "$found" = "N" ]; then
echo "No active interfaces...
dkyrtata,
Thanks for the quick reply. The bash one almost works as expected ..when it finds the active interface ..it prints both en1 and No active interfaces found ..like this
en1
No active interfaces found
Can you please correct that?
The script searches for active interfaces and returns the correct value except I want to also add a statement in there that returns "No active interfaces found" if there are truly no active interfaces.. having trouble adding an if/else statement in here? Any suggestions?
#!/bin/sh
for iface in...
The script searches for active interfaces and returns the correct value except I want to also add a statement in there that returns "No active interfaces found" if there are truly no active interfaces.. having trouble adding an if/else statement in here? Any suggestions?
#!/bin/sh
for iface in...
PHV -
I'm not sure what the '^' does but it didn't work. I just misplaced my backticks. Now it works. Nice try though. Appreciate the effort.
`ps -l -u squid | grep unlinkd | cut -c 96-102`
This command greps for 'unlinkd' which works fine
ps -l -u squid | grep unlinkd | cut -c 96-102
but as soon as I put it in a script ..the output is always the word 'UID'
Any one know why that is?
variable=(`ps -l -u squid` "| grep unlinkd | cut -c 96-102")
because I'm trying to use call this as a script in my customize prompt ..so when i go to any directory it will give me the total size of the directory I'm in automatically ..
ls –lR |awk '{total +=$5};END {print "Total size: " total/1024/1024 " Mb"}'
I'm trying to get the total size of the current directory including subdirectories with this command. Can't figure out why it gives me this message. Can someone provide some guidance? Thanks!
ls: –lR: No such file or...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.