• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Fwd: Shell problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: Shell problems


  • Subject: Fwd: Shell problems
  • From: Reinhold Penner <email@hidden>
  • Date: Sun, 8 Sep 2002 12:42:00 -1000

Bill Fancher was kind enough to point me in the right direction and for the benefit of the list, I'm forwarding his email. Bill was right on and his script did work as I had hoped it would.

Thanks Bill, -Reinhold

Begin forwarded message:

From: bill fancher <email@hidden>
Date: Sun Sep 8, 2002 10:11:52 Pacific/Honolulu
To: Reinhold Penner <email@hidden>
Subject: Re: Shell problems


On Sunday, September 8, 2002, at 12:43 PM, Reinhold Penner wrote:

I seem to be having problems with a shell command in a do shell script. So this works in the Terminal:

if (-e '/path2file1') cp -f '/path2file1' '/path2file2'

it will copy a file (path2file1) if that file exists and will do nothing if it doesn't. As soon as I pack the above into a do shell construct:

do shell script "if (-e '/path2file1') cp -f '/path2file1' '/path2file2'"

I will get an error < sh: -c: line 1: syntax error near unexpected token `cp' >

What am I doing wrong and is there another, maybe smarter, way to find out if a file exists and if so act upon it?

The shell that runs by default in terminal is tcsh. The shell run by do shell script is sh. To test your stuff you should execute sh in terminal so that you're testing against the right shell. The syntax is a little different for sh:

if test -e '/path2file1' ; then cp -f '/path2file1' '/path2file2'; fi

I didn't thoroughly test this, but at least sh doesn't complain about the syntax with the above.

HTH,
--
bill


-Reinhold
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Using Quark Dictionary Words in a List
  • Next by Date: Re: Shell problems
  • Previous by thread: Re: Shell problems
  • Next by thread: Re: Shell problems
  • Index(es):
    • Date
    • Thread