Thread Unterschiedliche Funktionen bei Console und Shell Ausführung (2 answers)
Opened by kami at 2010-03-31 14:32

kami
 2010-03-31 14:32
#135535 #135535
User since
2010-03-17
92 Artikel
BenutzerIn
[default_avatar]
Hi,

ich habe ein Perl-skript hier in verkürzter Funktion:
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
#!/usr/bin/perl -w

use strict;
use warnings;
use Getopt::Long;

use File::Copy;
use File::Spec;
use File::Glob ':glob';
use Archive::Rar;
my ($source_path, $test_check, $verzeichnis, $dest_path,$file); 
my %options = ();
GetOptions(\%options, 'test=s');

my $testdir='/home/kami/test';
my $test2dir='/home/kami/test2';

$verzeichnis=File::Spec->join($downloaddir, $options{'test'});


                                                                                        
$test_check=File::Spec->join($testdir, '*.test');

if(bsd_glob($test_check))
{  for $source_path (bsd_glob($test_check))  {
        if(-f $source_path)
         {   
           (undef,undef,$file) = File::Spec->splitpath( $source_path );
           $dest_path= $test_check=bsd_glob(File::Spec->join($test2dir, $file));
my $file2 = "/home/kami/scripts/test.txt";

open FILE3, ">$file2" or die "unable to open $file $!";
warn "oeffne jetzt die datei $file2";
print FILE3 $source_path."\n";
print FILE3 $dest_path."\n";
close(FILE3);
       
                 move($source_path,$dest_path) or die("ERROR move($source_path,$dest_path) $!\n");

         }
       }
  }


Das ich über folgendes Shell-Skript ausführe:
Code: (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
#!/bin/sh


FILEPATH="/home/kami/info"
CONFIG_FILE="$FILEPATH/config"
NOTIFY_FILE="$FILEPATH/notified"
ALL_FILE="/tmp/test.all"
TMP_FILE="/tmp/test.tmp"
LOCK_FILE="/tmp/test"

#calltest liefert daten.
# main
calltest -l | gawk '{
if ($1 != "Sum:" && $1 != "ID") {
print $1,$2
}
}' | while read id percent
do

reply="`calltest -t "$id" -i | grep -E '^ Name|^ test'`"

#echo $reply
name="`echo "$reply" | grep '^ Name' | cut -c 9-`"


# check that notification is not yet sent
grep -q "$hash" "$NOTIFY_FILE"
if [ $? = 1 -a "$percent" = "100%" ]
then

/home/kami/scripts/checkfiles.pl "-test=$name"
/home/kami/scripts/prowl.pl -application=test -event=test "-notification=$name"


echo "$hash" >> "$NOTIFY_FILE"
fi
echo "$hash" >> "$ALL_FILE"
done

# remove deleted torrents from sent notifications list
sort "$NOTIFY_FILE" > "$TMP_FILE"
mv "$TMP_FILE" "$NOTIFY_FILE"

sort "$ALL_FILE" > "$TMP_FILE"
mv "$TMP_FILE" "$ALL_FILE"

comm -1 -2 "$NOTIFY_FILE" "$ALL_FILE" > "$TMP_FILE"
mv "$TMP_FILE" "$NOTIFY_FILE"

exitAndClean 0


Hier läuft das Skript zwar durch aber es erfolgt keine ausgabe in dem TXT-File. Wenn ich das selbe Perl-Skript mit den gleichen Parameter über die Konsole ausführe, klappt alles ohne Probleme.

Ich weiß aber weil der Move-Befehl am Ende jedes mal ausgeführt wird, dass das Skript von den Abfragen bis dahin kommt. Also läuft es schon richtig. Leider bekomme ich vom Shell skript keine Ausgabe in der Konsole nur vom Perl-skript wenn ich das einzeln laufen lasse. Es tauche aber überhaupt keine Fehler auf.

Also woran kann das liegen? Wieso unterscheidet sich die Ausführung eines identischen Perl-Skripts in der Konsole von der durch ein Shell-skript?

Gruß kami

View full thread Unterschiedliche Funktionen bei Console und Shell Ausführung