Shell commands error 26

I am trying to run a shell command, curl, to transfer a newly created pdf file to a directory on my server. When I copy the the curl command into an actual shell window, it works. (I copied exactly what the program was sending to the shell by putting message box in the code then coping the message box and pasting it in a shell window: "msgbox (“curl -T “+ tRepName + " -u xxxxxx:xxxxxxxx” + Globals.PHONE+ “/”)” X’s have replaced the actual username and password for this posting, they are not in the actual shell command.

However, when run from the Xojo program, I get shell error 26 (text file busy??). I am using dbreports to generate the pdf file. I can see the pdf file appear in the save directory on the PC running the Xojo program. I have tried putting some for - next commands in to try to slow the program until the pdf file saves (not sure but thought that is what was busy), but that did not change anything. My code is below… any thoughts?

  tRepName = accountno + "FeeInvoice.pdf"
  selectedDir =DataDir.NativePath  + accountno + "_" + Globals.MailDate  + "Invoice.pdf"
  ReportSelect = True
  Dim fPDF as New FolderItem(selectedDir, FolderItem.PathTypeShell)      
  rpt.RenderToPDF fPDF
  tRepName = "/data" + Globals.PHONE + "/" + Globals.MailDate +"_" + accountno + "Invoice.pdf"

  for x = 1 to 200000
  Next X
  tRepName = accountno + "_" + GLobals.MailDate + "Invoice.pdf"
  Dim s As Shell
  s =New Shell
  s.Execute("curl -T " + tRepName + " -u xxxxxxx:xxxxxxxx" + Globals.PHONE+ "/")
  If s.ErrorCode <> 0 then MsgBox "Error code" + str(s.ErrorCode)

Should there be a “/” between data and Globals.PHONE?

No, the full directory name is data plus the phone number… so that part is correct.

This look weird to me (why change tRepName after the for - next?):

[code]tRepName = “/data” + Globals.PHONE + “/” + Globals.MailDate +"_" + accountno + “Invoice.pdf”

for x = 1 to 200000
Next X
tRepName = accountno + “_” + GLobals.MailDate + “Invoice.pdf”[/code]

My guess is that you are not using the full path with the second tRepName and curl can’t find the file you are trying to upload.

It seems my copy missed a couple of lines… the following is where the tRepName is changed:

  tRepName = "/data" + Globals.PHONE + "/" + Globals.MailDate +"_" + accountno + "Invoice.pdf"
  strSQl= "Insert into statements set FEEPATH = '" + tRepName +  "',  DATE= '" + Globals.MailDate + "', CLIENTPHONE = '" + ClientPhone + "',  CLIENTNAME = '" + ClientLast + "',  PW = '" + tax_id + "';"
  Dim tID as RecordSet = data.SQLSelect("select * from statements order by ID Desc")

It first puts the file name in a database, then it is modified to include the full path name for the curl command.

Can you add a TextArea to your project and do:

TextArea1.Text = s.Result


If s.ErrorCode <> 0 then MsgBox "Error code" + str(s.ErrorCode)

maybe that will help you to find the issue.

Edit: with this code:

Dim s As New shell s.Execute("curl -T /test.jpg") If s.ErrorCode <> 0 Then MsgBox "Error Code" + Str(s.ErrorCode) TextArea1.Text = s.Result
I get error 26 and this on the TextArea:

curl: Can't open '/test.jpg'! curl: try 'curl --help' or 'curl --manual' for more information
I don’t think 26 is a text file busy error.

It looks to me as if you’re trying to send the file before the process has finished writing and closed it.

Using that generic loop and counting to 200,000 is not the way to wait in this case.

You should get a folderitem on the new PDF file and check it until f.IsWriteable is True. IsWrietable will be false until the Text Busy flag is cleared. THEN send the file via curl.

Thank you Alberto and Tim… the IsWriteable was the property I was looking to use, and the text box lead me to the curl / ftp error I was receiving.