Hi I have a perl command that doesn't seem to be working correctly. It appears to be fine but even when i try and run it manually same thing. Can someone take a look at this and tell me what they think the problem could be?
Here is the perl Line:
system ("echo 'ssh -t -t $user\@$_ \"cd $user_path; perl check_file.pl $email\" >> $upload_dir/$timedata/scp_log 2>&1' >> $upload_dir/waiting_list"
Now here is the manual line:
ssh -t -t john@myhostname 'cd /home/john/www/scripts;perl check_file.pl my_email@email.com'>> /home/john/www/test_log1 2>&1
When i didn't have the "cd" in the script, it just wouldn't work. Now when i had the cd option there the script processes but it i get a error saying:
sh: <application>: not found
but if i run the script manually by going to the file and typing
./check_file.pl my_email@email.com
works perfectly. starting to get frustrated here.
---------- Post updated at 01:33 PM ---------- Previous update was at 01:23 PM ----------
also to add i'm using aix 6.1
You have written a perl script which generates shell scripts by running a shell script, which generates shell scripts and writes them to a file, presumably to run it in another shell later.
That's at least three separate, independent shells you're running there, to handle one line of "perl". If you have lots of system calls like this, your perl script is probably just thinly-disguised and uglified pure shell code, run with extraordinary inefficiency.
Could we see more of your code? I suspect the problem will become more evident. As well as better ways to solve the problem.
Try this format:
system( "ssh -t -t $user\@$_ 'cd $user_path; perl check_file.pl $email >>$upload_dir/$timedata/scp_log 2>&1' >>$upload_dir/waiting_list" )
I figured it out... thanks to all of those who tired to help.
The problem is this:
because the variables are set on that local user ID and not in the
/etc/profile
it was not noticing the program because it didn't know where to look. i just added for the program to execute the .profile before it continues anything.