Problem while scp if bashrc calls Perl script

A weird thing, happened today: When i do SCP from a remote server, file is not getting copied to here.

Application Server: Here is where i work, and have a login. I have several tweaks in .bashrc, and along with all those, today i called a PERL script from bashrc. So when ever i do scp from a remote server to this, as

scp test-file mylogin@server-app

It does not copies the file, also the normal 100% copying thing is also not displayed....

I started debugging, and found that when i have a print statement in the perl program, this is happening. If i comment out all the print statement then copy happens without any issue.

So, could somebody know what is the reason for this ? And how could i have both the thing operational, i want to print, also i would want the copy to happen successfully.

Can you confirm the scp command again? You need add the path next to remote server, such as:

scp test-file mylogin@server-app:/PATH

Yes, while adding PATH also it is not copying.

What could be the issue ?

Also, i get the following error/warning ( may not be relevant )

stty: standard input: Invalid argument

It seems the problem is related to the fact that the code is executed in a non-interactive context (no terminal attached).
It should be easier if you post a sample code that we can execute and reproduce the error.

  1. Example of the rc file entry.
  2. Example of how you are executing the code.

P.S. Try to add the following in the rc file before calling your scp/perl code and see how it behaves:

[ -t 0 ] && ...

@radoulov

Excellent, and Thanks.

While doing [ -t 0 ] && it works perfectly, also from some 'file test operators' manual i was able to understand this...

-tfile (descriptor) is 	associated with a terminal device
This test option may be used to check whether the stdin ([ -t 0 ]) or stdout ([ -t 1 ]) in a given script is a terminal.

Reference: Advanced Bash Shell Scripting Guide - File test operators