Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Wowzera

macrumors 6502a
Original poster
Oct 14, 2008
858
28
Brazil
Hello,

I'm trying to create a script that will do the following:

Open terminal;
"cd /Users/UserName/Desktop/TEMP";
"perl random.pl --out-prefix=result-regular --in-file=file.tar";
Wait 3 seconds;
"perl second.pl --out-prefix=result-different --in-file=file2.tar";
Wait 3 seconds;
"perl last.pl --out-final=name.tar *.rar";
Wait 3 seconds;
"rm *.zip";
"rm *.rar";
"rm *.rtf";
"cd /Users/UserName/Desktop";
Create a new folder called Name;
Drag name.rar to Name;

It may look a little complex, but it's related to simple terminal commands.
The one I tried to do stuck on using the command "cd", I can't change the default location. :(
 
You look about 4 commands from a shell script that you could just call from an applescript. Just use "sleep 3" to pause, mkdir to create a directory, and mv to move a file.

-Lee
 
You look about 4 commands from a shell script that you could just call from an applescript. Just use "sleep 3" to pause, mkdir to create a directory, and mv to move a file.

-Lee

Thanks for replying.
The main goal is to find the Desktop/TEMP folder. Since I will not know the username (it will run on other machines).
That perl scripts are a font things, I just edited it to make it simpler.
I just have no idea on how to do that.
 
Thanks for replying.
The main goal is to find the Desktop/TEMP folder. Since I will not know the username (it will run on other machines).
That perl scripts are a font things, I just edited it to make it simpler.
I just have no idea on how to do that.

I don't know if this is TOTALLY safe, but "cd" or "cd ~" will take you to the user's home directory no matter what... getting to the desktop should just be "cd ~/Desktop", but it may be possible to move this.

I don't know what you mean when you say the perl scripts are font things, so i'm not sure how to help you there.

-Lee
 
I don't know if this is TOTALLY safe, but "cd" or "cd ~" will take you to the user's home directory no matter what... getting to the desktop should just be "cd ~/Desktop", but it may be possible to move this.

I don't know what you mean when you say the perl scripts are font things, so i'm not sure how to help you there.

-Lee

Hello lee,

Thanks for replying again.
The perl scripts will be inside that TEMP folder. To execute them, all I need to do is type on the terminal window " perl scriptname.pl " and then the parameters for it.

So the applescript I am requesting will be:

cd to TEMP folder;
run these terminal commands (with a pause between them);
get the final file and move to a specified folder.
 
should just be:
Code:
cd ~/Desktop/TEMP
perl random.pl --out-prefix=result-regular --in-file=file.tar
sleep 3
perl second.pl --out-prefix=result-different --in-file=file2.tar
sleep 3
perl last.pl --out-final=name.tar *.rar
sleep 3
rm *.zip
rm *.rar
rm *.rtf
mkdir ~/Desktop/Name
mv name.rar ~Desktop/Name

-Lee
 
should just be:
Code:
cd ~/Desktop/TEMP
perl random.pl --out-prefix=result-regular --in-file=file.tar
sleep 3
perl second.pl --out-prefix=result-different --in-file=file2.tar
sleep 3
perl last.pl --out-final=name.tar *.rar
sleep 3
rm *.zip
rm *.rar
rm *.rtf
mkdir ~/Desktop/Name
mv name.rar ~Desktop/Name

-Lee

Thanks Lee.
Sorry, but it does not compile on the Applescript :(
As I have said, I'm total noob on it, I'm still reading lot of things but I didn't find any good examples to follow by far.
Could you tell me how do I make it run?
 
Code:
do shell script "cd ~/Desktop/TEMP
perl random.pl --out-prefix=result-regular --in-file=file.tar
sleep 3
perl second.pl --out-prefix=result-different --in-file=file2.tar
sleep 3
perl last.pl --out-final=name.tar *.rar
sleep 3
rm *.zip
rm *.rar
rm *.rtf
mkdir ~/Desktop/Name
mv name.rar ~Desktop/Name"

As stated, this is shell script. You might be able to do the same thing with "pure" applescript, but i have no idea how. This should run the shell script from an applescript.

-Lee
 
Code:
do shell script "cd ~/Desktop/TEMP
perl random.pl --out-prefix=result-regular --in-file=file.tar
sleep 3
perl second.pl --out-prefix=result-different --in-file=file2.tar
sleep 3
perl last.pl --out-final=name.tar *.rar
sleep 3
rm *.zip
rm *.rar
rm *.rtf
mkdir ~/Desktop/Name
mv name.rar ~Desktop/Name"

As stated, this is shell script. You might be able to do the same thing with "pure" applescript, but i have no idea how. This should run the shell script from an applescript.

-Lee

I figured it out now, after reading thousand of topics around the google search results.
Thank you so much for your kindness Lee :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.