473,385 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Assign program result or die

Hi,

I'm new to Perl and have a question about return statuses and
errorhandling. I want to do the following.

Execute a program and assign the result to an array and if the program
return an error I want to show the error. Something like this:

my @files = system("$ncftpls -1 -u $USER -p $PASSW
ftp:\/\/$HOST$remote_dir") && die "Could not execute NcFTPLS. Error:
$????";

Of course this does not work but maybe it shows what I want to do? How
do I get the error code ($????) from the program $ncftpls and how
should I write the code?

For info: $ncfptls is NcFTPLS found at http://www.ncftp.com/

Any hints?

Br,

Martin
Jul 19 '05 #1
1 3563
Martin Nilsson wrote:
I'm new to Perl and have a question about return statuses and
errorhandling. I want to do the following.

Execute a program and assign the result to an array and if the program
Do you mean result (= return value) or do you mean output?
return an error I want to show the error. Something like this:
You may want to read the first example in the man page for system().
my @files = system("$ncftpls -1 -u $USER -p $PASSW
ftp:\/\/$HOST$remote_dir") && die "Could not execute NcFTPLS. Error:
$????";
This assignment probably does not do what you assume it would do.
Please read the third and following sentences in the third paragraph of the
perldoc page for system().

Of course this does not work but maybe it shows what I want to do? How
do I get the error code ($????) from the program $ncftpls and how
should I write the code?
Assuming with "error code" you actually mean the return value, then please
read the first two and maybe the last sentence in the third paragraph of the
perldoc page for system().
Any hints?


Yep. Read the manual for the functions you are using: "perldoc -f system"
explains it all.

jue
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: steflhermitte | last post by:
Dear cpp-ians, I am working with a structure struct segment { .... vector <meta_segment>::iterator it_Z; .... };
6
by: AP | last post by:
Hello, I am having trouble trying to assign an object to a running program in windows in VB.NET A COM component class with the same name as the windows program is avaliable to use in VB.NET. The...
6
by: david | last post by:
I try to use "for" loop to retrieve and assign values in web form. The code is in the following. But it can not be compiled. What I want to do is: txtQ1.Text =...
11
by: skumar434 | last post by:
Hi everybody, I am faceing problem while assigning the memory dynamically to a array of structures . Suppose I have a structure typedef struct hom_id{ int32_t nod_de; int32_t hom_id;
21
by: vlsidesign | last post by:
This syntax does not to work nl, nt, ns = 0; The only one that get's initialized is ns. nl and nt because they don't initialize seem to get some junk from memory. I have done these two...
18
by: joaotsetsemoita | last post by:
Hello everyone, I'm having troubles assigning an onclick event to a cell. Im trying something like cursorPoint.cells.style.cursor = "hand"; cursorPoint.cells.width = "20";...
2
by: mguy27 | last post by:
I am working with VBA in ExcelUltimately I am trying to take a huge amount of data (9500-10000 rows) and do a search for text including the words "Violated Door". I then want to take the rows (which...
9
by: raylopez99 | last post by:
Just an observation: pens for drawing lines in Win Forms are tricky when assignment is inside the paint handler. inside of the Paint handler, but not inside a "using" brace (that is, outside of...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.