Using mail in Shell script
Hey guys,
I am writing a shell script to parse some data and create a csv file when done. I want to be able to email the csv file when the script is done. I cannot seem to figure out how to do this. I am running Mountain Lion and I have tried mail -s, mailx at the command line in Terminal and in the script and when I go check my gmail account there is no email there. Its not in the spam folders or the junk folder. Any help would be appreciated
Thank you for your reply earlier. Sorry I know that it was an applescript. I had a suggestion to send it via applescript: Here is the script that I wrote: It will send an email but the problem is that it fails right now cause the attachment is not working correctly.
-- Variables
set recipientName to "SomeOne"
set recipientAddress to "[email protected]"
set theSubject to "CSV File"
set theContent to "Here is your CSV file created from your website"
set fileName to "HD:Users:markperryman:GinaApp:gina_20120801.csv"
-- Mail Tell Block
tell application "Mail"
--Create the message
set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}
-- Set a recipient
tell theMessage
make new to recipient with properties {name:recipientName, address:recipientAddress}
tell content
make new attachment with properties {name:fileName as alias} at after the last paragraph
end tell
-- Send the Message
send
end tell
end tell
and here is the error I get now:
error "Mail got an error: Can’t make {name:alias \"HD:Users:someone:GinaApp:gina_20120801.csv\"} into type properties of attachment." number -1700 from {name:alias "HD:Users:markperryman:GinaApp:gina_20120801.csv"}
any ideas. Im at a loss right now.
I have a shell script written that does most of my process. Now I just want to write an applescript that can be called by the shell and send the email with the attachment. So Im not sure what Im doing wrong. As always any help would be appreciated.
Thanks
Similar Messages
-
Schedule workbook using with Unix shell script
Hi,
Can we schedule workbook using with Unix shell script?
Thanks,
JayI can't imagine how.
1. You can schedule Disco workbooks via Disco itself.
2. You can schedule Disco workbooks to run and output in different file formats automatically via batch scheduler in Windows running Disco Desktop directly (or can user VBasic).
3. You can schedule Disco workbooks to run and output in different file formats automatically via a Java program running the Java Command Line interface.
Moving forward, Oracle has announced that with a further interfacing of Disco with XML Publisher, you'll be able to use Oracle Apps concurrent manager and scheduling. But that's coming supposedly at the end of this year.
And I think that's about it.
Russ -
Tracking cpu used by a shell script
Hi,
We are on oracle 10.2.0.3 on solaris 8. I want to find how much cpu is used by a shell script. The script is having inside it a command to take full database export and create a log file that records when the activity started and ended also also sets up a few variables like sid oracle home etc. how can i find how much cpu is used by this script?
here is the script I have (after changing a few actual parameters)
+!/usr/bin/ksh+
export LOGFILE=db1_fullexport.log
export MAIL_LOG=/oracle/tmp/exp_mail.log
export ORACLE_HOME=/u01
export ORACLE_SID=db1
export NLS_LANG=AMERICAN_AMERICA.US7ASCII
export EXP_DIR=/d01
export DMP_DIR=/d01
echo "" > $MAIL_LOG
echo " ********** `date` LOGICAL BACKUP Log for $ORACLE_SID ON `hostname` *********** " > $MAIL_LOG
echo "" > $LOGFILE
echo "`date` Starting full export of $ORACLE_SID on `hostname`." >> $LOGFILE
echo "" >> $LOGFILE
echo "starting following is the PID of this script" >> $LOGFILE
echo $$ >> $LOGFILE
+$ORACLE_HOME/bin/exp dbauser/dbapwd full=y direct=y rows=n file=$DMP_DIR/db1_fullexp.dmp statistics=none log=$DMP_DIR/db1_fullexp.log >> $LOGFILE+
retstat=$?
echo "Export Return Status : $retstat " >> $MAIL_LOG
+if [ $retstat == 0 ]+
then
echo "For `date` on `hostname` and $ORACLE_SID database the logical backups are completed successfully." >> $MAIL_LOG
else
echo "Logical backups for `date` on `hostname` and $ORACLE_SID encountered some problems. Check!!!!!" >> $MAIL_LOG
fi
I can find the pid of the script but based on it how to find how much cpu it takes?
ThanksHi,
how can i find how much cpu is used by this script?I use a vmstat script. The vmstat utility show both user and system CPU and you can snap it at one scond intervals:
http://www.dba-oracle.com/t_oracle_unix_linux_vmstat_capture.htm
I have a book by Oracle Press, The Oracle UNIX adminustratun handbook" that you may find useful, and there is aslo a good book "Oracle Shell scripting" that has working examples in the code depot . . .
Inside Oracle, you can measure historical CPU, but this will not help your immediate goal . . .
http://www.dba-oracle.com/t_viewing_cpu_ram_io_costs.htm
Hope this helps . . .
Donald K. Burleson
Oracle Press author
Author of "Oracle Tuning: The Definitive Reference"
http://www.rampant-books.com/book_2005_1_awr_proactive_tuning.htm -
Setting from address on linux to receive the mail after shell script ran
Hi,
I scheduled some shell scripts on Linux as cronjobs. Once the shell scripts are executed at the scheduled timings i am receiving the mails as shown in the below. PRDORA, TSTORA, DEVORA are my environments.
From Subject Size Received
oracle dbora01cocen.corp.psi:PRDORA RMAN Archive Completed using Control file 11 KB Wed 8/13
[email protected] TSTORA:[14]ORA-12012: error on auto execute of job 854 10 KB Wed 8/13
[email protected] DEVORA:[7]ORA-12012: error on auto execute of job 1524 68 KB Wed 8/13
In the FROM address:
I should receive the mail format: oracle@hostname in the FROM address like shown below.
From Subject Size Received
[email protected] PRDORA01 RMAN Archive Completed using Control file 11 KB Wed 8/13
[email protected] TSTORA01:[14]ORA-12012: error on auto execute of job 854 10 KB Wed 8/13
[email protected] DEVORA01:[7]ORA-12012: error on auto execute of job 1524 68 KB Wed 8/13.
Rightnow this dbora01cocen.corp.psi is mixing up with the subject in PRDORA instead it should in the FROM address. Can anyone please guide where i am suppose to make modifications in order to get this change.
ThanksSorry for the Late Reply.
What does:
$ /bin/hostname
return for each of these environments?
FOR DEV:
[email protected][DEVORA01]% /bin/hostname
devora01coden.corp.psi
FOR TEST:
[email protected][TSTORA01]$ /bin/hostname
testora01coden.corp.psi
FOR PRD:
[email protected][PRDORA01]$ /bin/hostname
dbora01cocen.corp.psi
Are you using a local DNS or /etc/hosts entries to assign host names to IP addresses?I am not sure about this but i looked at /etc/hosts in each server and found the entry of the individual server on all the 3 servers.
Thanks -
Using a UNIX shell script to run a Java program (packaged in a JAR)
Hi,
I have an application (very small) that connects to our database. It needs to run in our UNIX environment so I've been working on a shell script to set the class path and call the JAR file. I'm not making a lot of progress on my own. I've attached the KSH (korn shell script) file code.
Thanks in advance to anyone who knows how to set the class path and / or call the JAR file.
loggedinuser="$(whoami)"
CFG_DIR="`dirname $0`"
EXIT_STATUS=${SUCCESS}
export PATH=/opt/java1.3/bin:$PATH
OLDDIR="`pwd`"
cd $PLCS_ROOT_DIR
java -classpath $
EXIT_STATUS=$?
cd $OLDDIR
echo $EXIT_STATUS
exit $EXIT_STATUSHi,
I have an application (very small) that connects to
our database. It needs to run in our UNIX environment
so I've been working on a shell script to set the
class path and call the JAR file.
#!/bin/sh
exec /your/path/to/java -cp your:class:paths:here -MoreJvmOptionsHere your.package.and.YourClass "$@"Store this is a file of any name, e.g. yuckiduck, and then change the persmissions to executechmod a+x yuckiduckThe exec makes sure the shell used to run the script does not hang around until that java program finishes. While this is only a minor thing, it is nevertheless infinite waste, because it does use some resources but the return on that investment is 0.
CFG_DIR="`dirname $0`"You would like to fetch the directory of the installation out of $0. This breaks as soon as someone makes a (soft) link in some other directory to this script and calls it by its soft linked name. Your best bet if you don't know a lot of script programming is to hardcode CFG_DIR.
OLDDIR="`pwd`"
cd $PLCS_ROOT_DIRVery bad technique in UNIX. UNIX supports the notion of a "current directory". If your user calls this program in a certain directory, you should assume that (s)he does this on purpose. Making your application dependent on a start in a certain directory ignores the very helpful concept of 'current directory' and is therefore a bug.
cd $OLDDIRThis has no effect at all because it only affects the next two lines of code and nothing else. These two lines, however, don't depend on the current directory. In particular this (as the cd above) does not change the current directory for the interactive shell your user is working in.
echo $EXIT_STATUS
exit $EXIT_STATUSEchoing the exit status is an interesting idea, but if you don't do this for a very specific purpose, I recommend not to do this for the simple reason that no other UNIX program does it.
Harald. -
Ls -l does not show files unless used in a shell script
Our backup script is generating files called BACKUP.01.04.05 (the 01.04.05 is a generated date). Well the files do not show up when using ls-l at the command line, except for the ones generated in 2000 (e.g. BACKUP.00.01.01). But if I put echo|ls -l in a script then the files do show up in the listing. We are running solaris 2.7. Any ideas? Thanks!
Hi there,
The behavior you described sure does not seem to make much sense.
Is it possible if the 'ls' in your command line is aliased to
something which might explain the behavior?
Also, echo|ls -l should not make a difference, I don't think ls takes
any input from the pipe. I assume that the 'ls' you run from the
shell script is different than the one you run from your command
line. The 'which ls' command will show if your ls is aliased.
Hope this helps.
Hae
Sun Technical Developer Support -
Using an external shell script rather than a main class
I've just started to use Creator and I'm like to replace the "Run" function with a call to a shell script. The projects are all libraries (no main class) so the shell script will copy the jar to a another location and perform some other tasks such as starting/stopping services.
I've tried uncommenting the target tag example in the build.xml file but that had no effect.
Any ideas?I've just started to use Creator and I'm like to replace the "Run" function with a call to a shell script. The projects are all libraries (no main class) so the shell script will copy the jar to a another location and perform some other tasks such as starting/stopping services.
I've tried uncommenting the target tag example in the build.xml file but that had no effect.
Any ideas? -
Using rsh within shell script unable to run CONCSUB utility.
I am writing a shell script which will connect to the application server from my DB server.
I am using RSH for the same and it is working. Now I want to submit Active Users Request using CONCSUB but
I am not finding correct syntax for the same.
I am able to execute adstpall.sh using the below combination of commands:
rsh <server> ". <SCRIPT_LOCATION>/adstpall.sh apps/paswd" > /usr/admin/scripts/my_direc
Similarly I want to execute CONCSUB but I am not finding the exact syntax for its execution from rsh.
Thank you very much.Hi,
Thank for the note IDs. But the issue is I am trying to connect to my application server from the DB server using RSH.
After connecting I am starting the application services using adstrtal.sh and post which I intend to do sanity check
by submitting Active Users from backend using CONCSUB utility.
I am getting the below message when trying to do so:
CONCSUB APPS/****** SYSADMIN "System Administrator" SYSADMIN WAIT=Y CONCURRENT FND FNDSCURS PROGRAM_NAME='"Active Users"'
++ CONCSUB APPS/******* SYSADMIN 'System Administrator' SYSADMIN WAIT=Y CONCURRENT FND FNDSCURS 'PROGRAM_NAME="Active Users"'
/oracle/admin/scripts/U_D/abc123/CONCSUB.sh: line 3: CONCSUB: command not found
I am able to execute CONCSUB within a shell script on my application server though (just placing the CONCSUB command within a file and executing it).
CONCSUB APPS/******* SYSADMIN "System Administrator" SYSADMIN WAIT=Y CONCURRENT FND FNDSCURS PROGRAM_NAME='"Active Users"'
+ CONCSUB APPS/******* SYSADMIN 'System Administrator' SYSADMIN WAIT=Y CONCURRENT FND FNDSCURS 'PROGRAM_NAME="Active Users"'
Submitted request 11897805 for CONCURRENT FND FNDSCURS PROGRAM_NAME="Active Users"
Normal completion
========
Please guide.
Thanks,
Farheen Rasul. -
Using cat in Shell Scripting for files
Hi,
I need a help in building a Shell Script file.
The Script File will do the activity of there are 2 files file_1.csv and file_2.csv.It will do the cat file1.csv file_2.csv > file_1.csv
Any help will be needful for me.Pl continue this discussion in your original post - FTPing multiple files in Server using Unix
I believe this has already been stated at Concatenating 2 files in Unix and passing as input to SQL loader program
This is now the second time you have been told to stay in that original post. -
Send mail through shell scripts
hi,
I am working in oracle9i and solaris 5.8 . i need to send a mail using the following codes
ORACLE_HOME=/oracle/u01/app/oracle/product/9.2.0; export ORACLE_HOME
ORACLE_SID=oracle; export ORACLE_SID
PATH=/oracle/u01/app/oracle/product/9.2.0/bin:/usr/bin:; export PATH
MAIL=/var/mail/dbacoe; export MAIL
BASE_SUPPORT_EMAIL=mail [email protected]
DATA_DIR=/oracle/sunora/
SHIP_IND=Lynn_FMLA.csv
uuencode $DATA_DIR/Lynn_FMLA.csv 'Lynn_FMLA.csv' | mailx -s 'Shipping Ind' $BASE_SUPPORT_EMAIL
me run this file in script.sh and i also give the full permission.. chmod 777 script.sh
after running this script i didnt get any error...
but in the mean time i didnt receive any mail...
please expalin me how to send a mil along with attachments using the scripts above...
Regs...try -
uuencode $DATA_DIR/Lynn_FMLA.csv Lynn_FMLA.csv | mailx -s 'Shipping Ind' $BASE_SUPPORT_EMAIL
No single quote around second file name.
rgds -
Connect to Home Computer using Mail / iChat / Automator / Script Editor
http://screenerschoice.com/video_tutorials/ScreenSharing/ScreenSharing.html
1. Start with Automator > Choose Custom Workflow
2. Drag Launch Application into the window and choose iChat
3. With whatever account you have signed at home (you need 2 accounts), make sure it is logged on. On automator, hit the Record button and Watch Me Do will start recording. (You have to do it in this sequence and no shortcuts or it can get hung up and not continue with the script.)
4. Choose the Finder > Applications > Type iChat > Hit Apple O (for open)
5. In the iChat window for your buddy list click once on the name you want to share with
6. Then on the top menu, go to Buddies > Share my screen with ....
http://screenerschoice.com/video_tutorials/ScreenSharing/Automator.png
7. Save this workflow as an application
8. Open Applications > Applescript > Script Editor
9. Hit Record
10. Go to Finder > Then keep going through until you find the application you just created and double click on it. Then hit stop on Script Editor.
11. Save this as an application as well. Mail will run these apps, but not the Automator apps.
12. Go to mail and go to rules
13. Create a rule with a few stipulations that will trigger the script. This way, not just anyone can send a script to your computer to control it. It would have to meet all the criteria you set it. Then in the action list in the rule, go to run applescript and choose the file you created with Script Editor.
14. In mail at the other computer, it needs to be set to check mail every so often. I do mine every minute.
15. Also on that computer, the finder window needs to be open. If it is not, the script will not run properly. I don't have time to figure out a workaround for that, so in the meantime, I just open the finder window and minimize it to my dock.Haven't tired it yet, but a thought would be to create an alias of iChat and place it on the desktop. Then save your scripts on the desktop as well. When you run everything from the desktop, you shouldn't have to have a Finder window open.
-
Is is possible to script telnet commands to port 25 automatically using a file, here document or re-directing stdin etc?
Yes. If you are on Solaris, use mconnect like so:
mconnect mailsrver.domain.com >> output_file <<__HEREDOC
smtp commands
quit
__HEREDOC
You could also use the Net::SMTP Perl modules. -
Moving files into directory using shell script
Can someone tell me how I move files into directory using *nix/linux shell script?
I have files which created from stored procedures using utl_file. The files name for example:
DKH_104_12345
DKE_101_42324242
DKH_102_32432
DKE_101_34553
Then I create directories automatically for example:
/oradata/apps/dmp/output/101
/oradata/apps/dmp/output/102
/oradata/apps/dmp/output/103
/oradata/apps/dmp/output/104
Using this procedure :
CREATE OR REPLACE PROCEDURE Xorganize AS
v_item VARCHAR2(5);
v_DirName VARCHAR2(50);
v_FileName VARCHAR2(50):='xorganize';
v_FileExt VARCHAR2(5):='.sh';
v_ID UTL_FILE.file_type;
CURSOR res IS
--find the directory name from table
SELECT brn_cde FROM vcr_brn_cde ORDER BY 1;
BEGIN
--used by utl.file funtion
SELECT PRD_DIR INTO v_DirName
FROM CR_SYS_PRM
WHERE CLT_CDE ='FIF';
SELECT v_FileName||v_FileExt INTO v_FileName FROM dual;
v_ID:=UTL_FILE.FOPEN(v_DirName,v_FileName, 'w');
utl_file.PUTF(v_ID,'%s\n','@@echo OFF');
utl_file.PUTF(v_ID,'%s\n','cls');
utl_file.PUTF(v_ID,'%s\n','echo Reorganizing ...');
OPEN res;
LOOP
FETCH res INTO v_item;
EXIT WHEN res%NOTFOUND;
utl_file.PUTF(v_ID,'%s\n','mkdir '||v_item);
END LOOP;
CLOSE res;
OPEN res;
LOOP
FETCH res INTO v_item;
EXIT WHEN res%NOTFOUND;
utl_file.PUTF(v_ID,'%s\n','move _'||v_item||'_.* '||v_item||'\');
END LOOP;
CLOSE res;
utl_file.PUTF(v_ID,'%s\n','FOR /F "usebackq delims=" %%1 IN (`dir /b *.`) DO @rd/q %%1');
utl_file.PUTF(v_ID,'%s\n','cls');
utl_file.PUTF(v_ID,'%s\n','echo Reorganizing ...Done');
utl_file.fclose(v_ID);
END;
Everything works fine, BUT, the script is generated in dos/windows scripting.
Now I need to run the script in *nix/linux shell, which I still can’t do it (because of my knowledge :p).
And also I don’t know if the script already generated in *nix/linux shell version, how do I chmod +x the script from stored procedure, I can’t use ‘host’ command in my tools
Thanks a lot
-firmanIf you're using 9i then UTL_FILE.FRENAME() will execute something like a Unix mv command.
If you want to do a chmod then you'll need to check out how to use a Java Stored Procedure to execute OS calls.
Cheers, APC -
Problems using Shell scripts and Automator
My problem is that when I use the "Run Shell Script" Automator action, it won't work if I type the script inside the action but it will work if I just type a path to the script file, which is less elegant as I then need to copy the Automator app made as well as the script file.
Here is the script I am trying to use
#!/bin/bash -f
if test -f ~/Library/Preferences/SPACE.com/Pro/Registration\ File
then
open -a /Applications/Starry\ Night\ High\ School/Starry\ Night\ High\ School.app/
else
ditto /Library/Management/Preferences/StarryNight/SPACE.com ~/Library/Preferences/SPACE.com
open -a /Applications/Starry\ Night\ High\ School/Starry\ Night\ High\ School.app/
fi
exit 0Well I found the problem. Or at least I got it to work. I tried typing simple commands and scripts into the Shell Script action and had no issues with it running. So I then slowly expanded and typed out my script:
#!/bin/bash -f
if test -f ~/Library/Preferences/SPACE.com/Pro/Registration\ File
then
open -a /Applications/Starry\ Night\ High\ School/Starry\ Night\ High\ School.app/
else
ditto /Library/Management/Preferences/StarryNight/SPACE.com ~/Library/Preferences/SPACE.com
open -a /Applications/Starry\ Night\ High\ School/Starry\ Night\ High\ School.app/
fi
exit 0
Having typed it out in the script it runs fine. It seems you can't paste text into the action. To test this hypothesis, I copied the working script out of automator into BBedit and then back into Automator, the script no longer worked. Not sure why that is happening, but it does work if I type the scripts out. -
Run Shell Script action forgets which shell to use
My workflow uses a python shell script. However, each time I load the workflow the action goes back to using bash. If I save the workflow as an application it works correctly. Am I doing something wrong or should I submit a bug report?
I tried adding #!/usr/bin/python as a workaround to the start of the script but it didn't work. I'm using 10.4.6
2Ghz MacBook Pro Mac OS X (10.4.5) 2GB RAM, Sony Artisan MonitorI don't think that combo box actually has a direct binding to the parameters of the action. It's sole function appears to be that of dumping templates into an otherwise blank text area.
Edit Actually it does have a binding, but it's a value binding, not index. Hmm. Could be worthy of a bug report.
Maybe you are looking for
-
Problems with NetWeaver 7.10 during/after patching SAP_ABA
Hi! I have installed NetWeaver 7.10 and have started to patch the system with SAP_ABA from level 3 to 6, SAP_BASIS has already been imported without any issues. I then started the import and it looked like it was running, but there where no status ch
-
I can not type a url in the browser window when I open a new tab. Why not?
I open a new tab click in browser window and see cursor but it does not blink. If I click in google search window it works fine. I can redirect using bookmarks but if I want to just type it in, it acts blocked or locked. Could I have done something t
-
i have video that i want to embed in another video that play at the same time. can imovie 8 do it? i have video driving my car front and rear view. i want to embed the rear view video in the front view so it looks like a rear view mirror view and the
-
HT4436 Where do I find what iOS I have on my iPad first generation?
How do I transfer photos from my iPad first generation to my new iPad2? I cannot figure out if iCloud is available on the original iPad because I cannot figure out the iOS on the original iPad.
-
Queries running on current database.
Kindly let me know the sql query to find the backend queries currently running on current database. Thanks in Advance. Regards, Ranjjeet K