- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: about Shell Variable
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 01:01 AM
08-24-2005 01:01 AM
# ( uuencode "hhawmail.sh" "hhawmail.sh"; uuencode "test_hhawmail.sh" "test_hhawmail.sh" ) | mailx -m -s "test" abc@domain.com
I used shell variable "$test":
# test='uuencode "hhawmail.sh" "hhawmail.sh"; uuencode "test_hhawmail.sh" "test_hhawmail.sh"'
# echo $test
uuencode "hhawmail.sh" "hhawmail.sh"; uuencode "test_hhawmail.sh" "test_hhawmail.sh"
But I failed to run the following:
# ( ${test} ) | mailx -m -s "test" abc@domain.com
"hhawmail.sh": No such file or directory
Null message body; hope that's ok
So, how should I embed "$test" to that command line to let it work exactly like:
# ( uuencode "hhawmail.sh" "hhawmail.sh"; uuencode "test_hhawmail.sh" "test_hhawmail.sh" ) | mailx -m -s "test" abc@domain.com
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 01:06 AM
08-24-2005 01:06 AM
Re: about Shell Variable
Double quote whole thing.
Also
test='(uuencode "hhawmail.sh" "hhawmail.sh"; uuencode "test_hhawmail.sh" "test_hhawmail.sh")'
should also work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 01:21 AM
08-24-2005 01:21 AM
Re: about Shell Variable
1. test="uuencode hhawmail.sh hhawmail.sh; uuencode test_hhawmail.sh test_hhawmail.sh"
2. ( ${test} ) | mailx -m -s "test" abc@domain.com
But not sure about the attachment , need to try out..
Cheers ,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 01:21 AM
08-24-2005 01:21 AM
Re: about Shell Variable
First off, it's a bad idea in general to use variable names that are commands. "test" is actually a command. It's not your problem here, but I'm just letting you know.
runcmd="uuencode hhawmail.sh hhawmail.sh; uuencode hhawmail.sh hhawmail.sh"
$runcmd | mailx -m -s "test" abc@domain.com
now works.
So to assign your command string to the runcmd variable, you just need to enclose the whole command in a single set of quotes. If you're intent on using the quotes around the filename names, the you should put a "\" in front of each quote " character that surrounds each filename.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 01:30 AM
08-24-2005 01:30 AM
Re: about Shell Variable
1. double quote:
# test="uuencode "hhawmail.sh" "hhawmail.sh"; uuencode "test_hhawmail.sh" "test_hhawmail.sh""
# echo $test
uuencode hhawmail.sh hhawmail.sh; uuencode test_hhawmail.sh test_hhawmail.sh
# ( ${test} ) | mailx -m -s "test" abc@domain.com
But I got an email without attachment, and with email body:
Usage: uuencode [ source ] remotedest
2.
# test='( uuencode "hhawmail.sh" "hhawmail.sh"; uuencode "test_hhawmail.sh" "test_hhawmail.sh" )'
# echo $test
( uuencode "hhawmail.sh" "hhawmail.sh"; uuencode "test_hhawmail.sh" "test_hhawmail.sh" )
# $test | mailx -m -s "test" abc@domain.com
ksh: (: not found
Null message body; hope that's ok
# ( ${test} ) | mailx -m -s "test" abc@domain.com
ksh: (: not found
Null message body; hope that's ok
But why I can use the following to get two attachments correctly:
# ( uuencode "hhawmail.sh" "hhawmail.sh"; uuencode "test_hhawmail.sh" "test_hhawmail.sh" ) | mailx -m -s "test" abc@domain.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 01:33 AM
08-24-2005 01:33 AM
Re: about Shell Variable
You have to use runcmd like this , else give error,
(${runcmd})| mailx -m -s "test" abc@domain.com
Cheers ,
Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 01:38 AM
08-24-2005 01:38 AM
Re: about Shell Variable
WILL WORK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 01:41 AM
08-24-2005 01:41 AM
Re: about Shell Variable
# runcmd="uuencode hhawmail.sh hhawmail.sh; uuencode hhawmail.sh hhawmail.sh"
# echo $runcmd
uuencode hhawmail.sh hhawmail.sh; uuencode hhawmail.sh hhawmail.sh
# $runcmd | mailx -m -s "test" abc@domain.com
I got an email without attachment, and with email body:
Usage: uuencode [ source ] remotedest
Still not the same as I ran directly:
# ( uuencode "hhawmail.sh" "hhawmail.sh"; uuencode "test_hhawmail.sh" "test_hhawmail.sh" ) | mailx -m -s "test" abc@domain.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 01:41 AM
08-24-2005 01:41 AM
Re: about Shell Variable
Because uuencode syntax you are writing is worng .
it should be like that :
# uuencode file1 file1 | mailx -s 'new program' friends@email.com
And you will get the attachment ,
---------------------------------
For getting dual attachment , do this :
$ (uuencode file1 file1 ; uuencode file2 file2 ) | mailx -m -s "Dual Attachment Test" abc@domain.com
--------------------------------
Hope you got the solution ,
Cheers ,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 01:45 AM
08-24-2005 01:45 AM
Re: about Shell Variable
I tried:
# ( ${runcmd} ) | mailx -m -s "test" abc@domain.com
But same error
I got an email without attachment, and with email body:
Usage: uuencode [ source ] remotedest
Still not the same as I ran directly:
# ( uuencode "hhawmail.sh" "hhawmail.sh"; uuencode "test_hhawmail.sh" "test_hhawmail.sh" ) | mailx -m -s "test" abc@domain.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 01:50 AM
08-24-2005 01:50 AM
Re: about Shell Variable
# runcmd='\( uuencode hhawmail.sh hhawmail.sh; uuencode hhawmail.sh hhawmail.sh \)'
# echo $runcmd
\( uuencode hhawmail.sh hhawmail.sh; uuencode hhawmail.sh hhawmail.sh \)
# $runcmd | mailx -m -s "test" abc@domain.com
ksh: \(: not found
Null message body; hope that's ok
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 02:11 AM
08-24-2005 02:11 AM
Re: about Shell Variable
Now I am going to mail two attachments, I don't have problem to run:
# ( uuencode "hhawmail.sh" "hhawmail.sh"; uuencode "test_hhawmail.sh" "test_hhawmail.sh" ) | mailx -m -s "test" abc@domain.com
or
# ( uuencode hhawmail.sh hhawmail.sh; uuencode test_hhawmail.sh test_hhawmail.sh ) | mailx -m -s "test" abc@domain.com
But when I used shell variable, then failed.
I have to use shell variable in the shell script, how can I make it?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 02:22 AM
08-24-2005 02:22 AM
Re: about Shell Variable
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 02:25 AM
08-24-2005 02:25 AM
SolutionHere is the solution,
For taking it in single variable its giving error at "(" , hence you have to take in 2 variable , one for Command , one for file(s).
So here we go :
---------------------------------------------------------------------------------------
#!/usr/bin/ksh
############################################
# Storing Variables,
UU_COM=uuencode ; FILE1=hhawmail.sh ; FILE2=test_hhawmail.sh
($UU_COM $FILE $FILE; $UU_COM $FILE2 $FILE2) | mailx -m -s "test" abc@domain.com
############################################
Do you get the email, with attachment. Pls update.
Cheers ,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 02:33 AM
08-24-2005 02:33 AM
Re: about Shell Variable
# uu_com=uuencode
# file1=hhawmail.sh
# file2=test_hhawmail.sh
# echo $uu_com
uuencode
# echo $file1
hhawmail.sh
# echo $file2
test_hhawmail.sh
# ( $uu_com $file1 $file1; $uu_com $file2 $file2 ) | mailx -m -s "test" abc@domain.com
Now I can get two attachemnts without error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 02:46 AM
08-24-2005 02:46 AM
Re: about Shell Variable
Happy to know that its working ..and enjoy this Forum.
Cheers ,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 02:56 AM
08-24-2005 02:56 AM
Re: about Shell Variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 04:50 AM
08-24-2005 04:50 AM
Re: about Shell Variable
You could always do the following within your shell script:
============================================================
# test="uuencode hhawmail.sh hhawmail.sh; uuencode test_hhawmail.sh test_hhawmail.sh"
# (echo $test | /usr/bin/sh ) | mailx -m -s "test" abc@domain.com
============================================================
cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 04:57 AM
08-24-2005 04:57 AM
Re: about Shell Variable
============================================================
# test="uuencode hhawmail.sh hhawmail.sh; uuencode test_hhawmail.sh test_hhawmail.sh"
# (echo $test | sh ) | mailx -m -s "test" abc@domain.com
============================================================
regards!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 05:47 AM
08-24-2005 05:47 AM
Re: about Shell Variable
I tried what I could imagine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 06:42 AM
08-24-2005 06:42 AM
Re: about Shell Variable
:)
cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 08:24 AM
08-24-2005 08:24 AM
Re: about Shell Variable
You gave me the final solution for my case, which is exactly what I want!
Thanks!
Points added!