Thread quoten (Shell Aufruf)
(13 answers)
Opened by wenze at 2018-08-20 13:29
Hier liegt der Hase im Pfeffer:
near "my $command = qq( su - $sidadm -c "cat / dev" (Might be a runaway multi-line // string starting on line 170) (Do you need to predeclare my?) Hier der Code ab Zeie 150 bis Ende. Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 ######################################################################################################### # get dbhost from /usr/sap/<SID>/SYS/profile/DEFAULT.PFL ######################################################################################################### sub DBhost { my $file = "/usr/sap/$_[0]/SYS/profile/DEFAULT.PFL"; my $search = 'dbhost'; open my $fh, '<', $file or die "open($file,ro) failed: $!"; my $seen = ' '; my $third = ''; LINE: while ( my $line = <$fh> ) { # skip lines without search string next LINE if index( lc($line), lc($search), 0 ) < 0; # extract the third field of line $third = ( split( ' ', $line, ) )[2] // ''; if ($third) { last } # keep the fields uniq #$third unless $third eq $seen; #$seen = $third; } return $third; } ######################################################################################################### # delete OS mails ######################################################################################################### sub DEL_mail { my $sidadm = $_[0]."adm"; my $command = qq( su - $sidadm -c "cat /dev/null > /var/spool/mail/$sidadm" ); system( $command ) == 0 or die "Failed <$command>: $!"; #system ("su - $sidadm -c /" echo //'d *//' | mail -N//""); } ######################################################################################################### # get OS Level ######################################################################################################### sub OS_Level { my $OS_Level; my $osname=$Config{osname}; #print "$osname \n"; switch ($osname) { case "aix" { $OS_Level = `oslevel -r`; } case "linux" { $OS_Level = `cat /etc/issue| awk '{print \$3, \$7, \$8}'| tr "\n" " "| tr -d [:blank:]`; } } #print "$OS_Level \n"; chomp $OS_Level; return $OS_Level; } exit Last edited: 2018-08-21 16:41:40 +0200 (CEST) |