Perl Exception - $!,$?,$@


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl Exception - $!,$?,$@
# 8  
Old 08-27-2008
Java

Quote:
Originally Posted by era
My guess is that the misplaced comma in your third segment is causing the error to be lost. You probably mean die "Can't ftp the file: $!" rather than (die "Can't ftp the file"), $! which is what your code currently seems to do, if I managed to get the precedence right.

Where in your code is there a reference to Local file test2.log? Is that the file you are attempting to upload? (What's the value of $filename?)
Thanks for your response. I know the filename is invalid.Basically am trying to workout on the exception handling mechanism, where exceptions from all the above statements like,creating ftp object,loggging,change directory etc are trapped in $@ and print only if i give a print statement in the catch block or if($@) block.

But in this case alone ie,putting the file to remote server,error is thrown to the STDOUT/STDERR along with trapping it in $@.I am wondering about this behaviour and looking for the reason and solution.

Unfortunately, the possibility you had given(comma) is not the trum card!
# 9  
Old 08-27-2008
Bug

Hi,

I got a little clue about the reason.Thanks otheus to make me look into the source code of Net::FTP module.Your doubt is correct,this module is the core reason for this behaviour

In this module,in situations like can't able to open the file due to permissions,invalid filename etc. 'carp' method in 'Carp' module is called,which will act exactly like inbuilt method 'warn'.The exceptions or control thrown using 'warn' is not possible to trap using a $@ and it won't be get set in this case also.So the message is thrown out to the STDOUT/STDERR.

One question i have to you guys is how to trap or prevent this from being printed into the console.I know i can do it by redirecting the output or error message and all.But i want it to be trapped...Anyone please!

Regards
Dileep
# 10  
Old 08-28-2008
You can set up a pseudo-signal handler $SIG{__WARN__} to circumvent or modify warnings.
# 11  
Old 08-28-2008
MySQL

Hi,

Let me try out that era. Thanks for your help guys!

With Regards
Dileep Pattayath
# 12  
Old 08-28-2008
If you don't have the latest version of this module, get it from CPAN. If you do have it, bitch to the authors -- that sounds like sloppy module writing to me. Good luck on your project!
# 13  
Old 08-31-2008
MySQL

Quote:
Originally Posted by otheus
If you don't have the latest version of this module, get it from CPAN. If you do have it, bitch to the authors -- that sounds like sloppy module writing to me. Good luck on your project!
Sure.Let me check.Thanks otheus
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Monitor logs for exception and if exception come then sent an email

Hi Folks, please advise , I have logs generated on unix machine at location /ops/opt/aaa/bvg.log , now sometimes there come exception in these logs also, so I want to write such a script such that it should continuously monitor these logs and whenever any exception comes that is it try to find... (3 Replies)
Discussion started by: tuntun27272727
3 Replies

2. Shell Programming and Scripting

Re: exception using AWK

I have following file: NAME=ora.DG1.svc TYPE=ora.service.type CARDINALITY_ID=1 TARGET=ONLINE STATE=ONLINE NAME=ora.orlene.DG2.svc TYPE=ora.service.type CARDINALITY_ID=1 TARGET=ONLINE STATE=OFFLINE NAME=ora.MN.acfs TYPE=ora.registry.acfs.type TARGET=ONLINE (4 Replies)
Discussion started by: rcc50886
4 Replies

3. Solaris

solaris 7 exception

Hi all, An application works well under 2.6 but under 7 it gives TEXT_IO exceptions. (Is_Open, Check_Is_Open, Get_Line procedures). Any idea? Regards (3 Replies)
Discussion started by: endoavour
3 Replies

4. Programming

Exception Handling C++

Hello All, I have a question ....which I am totally confused about! If I have a fxn foo in a program which returns a logical value. But it has a posssiblity to throw some exception. Now my exception handler returns a value as a string stating why the exception occured. But my... (1 Reply)
Discussion started by: mind@work
1 Replies

5. Shell Programming and Scripting

Exception handling

Sometimes when I try to use curl to upload to an ftp server, I get the message: $curl -T file.wmv ftp.eu.filesonic.com --user user:password curl: (8) Got a 421 ftp-server response when 220 was expected How do I get the script to try again if I get the message curl: (8)? (2 Replies)
Discussion started by: locoroco
2 Replies

6. Linux

MMU exception

I hope to post in the right forum, otherwise I apologize for this. if a MMU exception is caused by a process which tries to access to other memory segment (out of its own address space) what the kernel does in this case ? maybe kernel kills the "bad" process ? (2 Replies)
Discussion started by: Puntino
2 Replies

7. UNIX for Dummies Questions & Answers

How to catch the exception

Dear friends, I am transferring some files to a windows system from Unix m/c thru FTP Script given below. echo "open $host quote USER $userid quote PASS $pwd $verbose $type cd $dir bin put $file close quit"|$ftp... (0 Replies)
Discussion started by: Vijayakumarpc
0 Replies

8. HP-UX

Help with RPC Exception

Hi, I am trying to use swremove to remove some old software packages before an upgrade. I keep getting the same error below. I have restarted swagent, i have killed the swagent process and started it, and I have restarted the entire system. I have now run out of ideas. Anyone know what the problem... (2 Replies)
Discussion started by: ejbrever
2 Replies

9. UNIX for Advanced & Expert Users

RPC Exception - Help

Hi, I am trying to use swremove to remove some old software packages before an upgrade. I keep getting the same error below. I have restarted swagent, i have killed the swagent process and started it, and I have restarted the entire system. I have now run out of ideas. Anyone know what the problem... (0 Replies)
Discussion started by: ejbrever
0 Replies

10. UNIX for Advanced & Expert Users

exception handling

Does exception handling exist in any UNIX enviornment? I develop on Windows MSVC++ land and need to port to UNIX. (1 Reply)
Discussion started by: RichardS
1 Replies
Login or Register to Ask a Question