Jump to content

Shell Commands - help please


This topic is 6917 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I need some assitance with a shell command.

How can I use a shell command to export a set of related records with the file name set to be the related field?

I have the database for a newspaper website, all stories entered by issue umber- there are over 300 issues.

I have a script that finds the related fields, and exports them, but i currently have to manually enter the issue number for the file name. I don't really want to have to type "issue650.txt" issue651.txt etc...

any ideas?

THANKS!

Link to comment
Share on other sites

this applescript shell script will rename an exported file called "export.txt" in the path shown, to whatever name you have stored in field NewFileName

"do shell script "mv ~/desktop/FMExportFolder/output.txt ~/desktop/FMExportFolder/"& "newfile.txt" & """

Link to comment
Share on other sites

when i enter that shell script I get an error message...

"Expected "given","in", "of" expression, "with". "without"< other parameter name, etc. but found token

then it highlights the after script

WHAT on earth does that mean

oh and THANK YOU THANK YOU

Link to comment
Share on other sites

Sorry, I gave you the syntax for FM version 7 which uses a different character to escape the quotation marks. Also, in version 6 it needs to be entered as a formula in a calculation field, and then you specify the calc field in the perform applescript step. Here is the correct syntax:

"do shell script ""mv ~/desktop/FMExportFolder/output.txt ~/desktop/FMExportFolder/"& NewFileName & """"

Also see the attached example file.

TestShellScript.fp5.zip

Link to comment
Share on other sites

Going nuts here

i can change the file name when in Applescript

do shell script "mv ~/desktop/FMExportFolder/output.pdf ~/desktop/FMExportFolder/newfilename.pdf"

but when i add it to filemaker so I can use a Field it doesnt work

"do shell script "mv ~/desktop/FMExportFolder/output.pdf ~/desktop/FMExportFolder/"&"transmittal number"&"""

where transmittal number is the Field i want to use.

As a secondary question to add an extension do i just use

/"&"transmittal number"&".pdf""

thanks

Link to comment
Share on other sites

You can't just address a FileMaker field by typing its name as text. You address it as a cell, setting its value into an AppleScript variable.

set transmittal to cell "transmittal number" of current record

(This would be in a FileMaker Perform AppleScript step. Otherwise, from Script Editor you'd need to be inside a "tell FileMaker" block.)

Then you can use that in your line (shortened so I could test it easily)???

set transmittal to cell "transmittal number" of current record & ".pdf"

do shell script "mv ~/desktop/output.pdf ~/desktop/" & transmittal

Link to comment
Share on other sites

sorry to be dense but when I try to send accross netwrok I get more errors

is this right to use the ip number?

set transmittal to cell "transmittal number" of current record & ".pdf"

do shell script "mv ~/desktop/transmittal.pdf IP number/volumes/server HD/folder/"& transmittal

Link to comment
Share on other sites

The space in "Server HD" may be causing a problem. Try changing it to "Server HD"

If that doesn't work, you may have to try the following:


do shell script "mv ~/desktop/transmittal.pdf afp://username:password@IPaddress/volumes/server HD/folder/"& transmittal 





I don't know if you can reference the remote file without mounting the remote volume first or not. Otherwise you may have to do something like this:





# This should all be on one line

do shell script "mkdir /Volumes/MyTempVolume;

    mount -t afp afp://username:password@IPaddress/volumes/server HD/folder/ /Volumes/MyTempVolume;

     mv ~/desktop/transmittal.pdf /Volumes/MyTempVolume"& transmittal

Link to comment
Share on other sites

  • 2 weeks later...

I have discovered to cope with a space in the file path, you need two backslashes eg server HD when running a shell script from filemaker or applescript. One backslash if renning directly from the terminal.

Link to comment
Share on other sites

This topic is 6917 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.