Playing with parameters


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Playing with parameters
# 1  
Old 02-20-2011
Playing with parameters

Can someone help me of doing something like this


send.sh
Code:
#!/bin/bash

for last; do true; done
echo $* | gammu sendsms TEXT $last

every thing is good except that when i launch the script like this
Code:
./send.sh This is the message i want to send +63922XXXXXXX

it turned out the message of the reciepient is "This is the message i want to send +63922XXXXXXX"

it included the recipient's own number,
i tried using quote but im having problems when im using it of runtime.exec() on java so now im forced to do the script on a series of paramaters using $*
Code:
i want something like this to happen, when i execute

./send.sh This is the message i want to send +63922XXXXXXX

i want to user only to recieve
Code:
"This is the message i want to send" and send it to +63922XXXXXXX

not
Code:
"This is the message i want to send +63922XXXXXXX" and sends to +63922XXXXXXXX


Last edited by Franklin52; 02-21-2011 at 02:55 AM.. Reason: Please use code tags, thank you
# 2  
Old 02-20-2011
How about this:

Code:
#!/bin/bash
while [ $# -gt 1 ]
do
   msg="$msg $1"
   shift
done
echo $msg | gammu sendsms TEXT $1

or

Code:
#!/bin/bash
echo ${@:1:$# - 1} | gammu sendsms TEXT ${@:$#}


Last edited by Chubler_XL; 02-20-2011 at 07:41 PM..
# 3  
Old 02-21-2011
This solved the problem thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

sed command playing with me!

Hello guys, I was working with my data (a tab delimted text file) in Linux and wanted to replace all "NaN" values in my huge table with "NA", so i used the following sed command: sed 's/NaN/NA/g' /filepath -> outputfile.txt The results were good, all "NaN" were replaced with "NA", but the... (7 Replies)
Discussion started by: Error404
7 Replies

2. Shell Programming and Scripting

Playing with httpd.conf

Hello Guys !! wanted to use SED to pull cout the full vertualhost entry for domain which is specified from command line Like (IP base httpd.conf) domain="ServerName takemewithyou.in" sed -n '/<VirtualHost* $domain/,/<\/VirtualHost>/p' httpd.conf File can take to test is below ... (0 Replies)
Discussion started by: SilvesterJ
0 Replies

3. Linux

Playing with the Linux Scheduler

Hi, To begin with let me explain my system and then I will come to the problem. System: My program forks 2 child processes. These child processes further start 2 user level threads (pthreads) and 2 kernel level threads (kthread). All these threads issue various system calls. I am using... (1 Reply)
Discussion started by: demigod85
1 Replies

4. UNIX for Dummies Questions & Answers

Crontab not playing

This is my crontab: MAILTO="" # m h dom mon dow command # Check to see if the fridge door has been left open * * * * * fridgedoor #Get temperature readings from fridge and save to monthly file in Downloads 30 0,4,8,12,16,20 * * * fridge 40 0 * * * sendfridge * * * * *... (2 Replies)
Discussion started by: Fitch
2 Replies

5. AIX

tuning network parameters : parameters not persist after reboot

Hello, On Aix 5.2, we changed the parameters tcp_keepinit, tcp_keepintvl and tcp_keepidle with the no command. tunrestore -R is present in inittab in the directory /etc/tunables we can clearly see the inclusion of parameters during reboot, including the file lastboot.log ... (0 Replies)
Discussion started by: dantares
0 Replies

6. UNIX for Dummies Questions & Answers

playing games from another directory?

If "photopia.dat" is a game. To play it, you would normally type "frotz photopia.dat" (assuming you are in the directory where photopia.dat resides). But what if I'm in my home directory, photopia.dat is in the "games" directory, and I want to play it without switching directories? What command... (2 Replies)
Discussion started by: greeky
2 Replies

7. Programming

Playing Audio files in C

Hi All, Looking for an assistance on how to access the speakers of my machine and play audio files using C. Any tutorials will be of great help. Regards, Sayantan. (1 Reply)
Discussion started by: Sayantan
1 Replies

8. SCO

Help! Playing with Xenix!

Hey everyone! I'm trying to retrieve old files from my Xenix computers. So the option I've now come down to is to load up a second harddrive and do a doscp of my tar'd backup file. Now, How do I go about this? I am not a unix user myself so I'm not quite sure. I need help! I have a VERY short... (1 Reply)
Discussion started by: Slaughter
1 Replies

9. UNIX for Dummies Questions & Answers

playing audio

Hi all, I play audio through the web browser and it plays ok on windows. When i try the same thing on unix i get the error message "sh: /usr/local/bin/sox: not found. I've tried 'locate sox' and can't seem to find it. Is there some way I can change the browser settings so they play the audio... (3 Replies)
Discussion started by: molli_81
3 Replies
Login or Register to Ask a Question