variables on solaris?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting variables on solaris?
# 1  
Old 05-08-2008
variables on solaris?

Im a newb with solaris... I cant get this simple variable to work under almost any shell? Im a linux guy and this type of variable works fine under linux, so I dont understand why its not working under solaris...

export YSD="date -d '-1 day' '+%m-%d-%y'"
$YSD
date: extra operand `\'+%m-%d-%y\''

Why is it adding in the backslashes? Smilie
# 2  
Old 05-08-2008
ohh, under linux I would use the following for the variable with bash if it makes any difference..

YSD=$(date -d '-1 day' '+%m-%d-%y')

and all works well...
# 3  
Old 05-09-2008
The -d option is unique to the GNU version of the date command, which you do not normally find on Solaris.
# 4  
Old 05-09-2008
Quote:
Originally Posted by Annihilannic
The -d option is unique to the GNU version of the date command, which you do not normally find on Solaris.
im using gnu date, still even with the -d option removed, I still get those \ added in when calling the variable.
# 5  
Old 05-09-2008
Where are the backquotes in your code, it's not clear from your previous post. Maybe try posting between code tags?

Code:
export YSD=`date -d '-1 day' '+%m-%d-%y'`

# 6  
Old 05-09-2008
Quote:
Originally Posted by Annihilannic
Where are the backquotes in your code, it's not clear from your previous post. Maybe try posting between code tags?

Code:
export YSD=`date -d '-1 day' '+%m-%d-%y'`


uh ohh.. I wasnt using back quotes. I guess that is the problem. I was just using double quotes around the command. I should be using backquotes around the command then? i.e. like you just posted?
# 7  
Old 05-09-2008
Aweomse! Annihilannic thank you very much, my script is working now. I had the syntax wrong and you pointed out the backquotes to me. I can't believe it took me 10 minutes to write it under linux, but it took 2 days to get it moved over to solaris Smilie

Thanks for the help.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Solaris 8 ssh issue - $SSH_ORIGINAL_COMMAND undefined variables

I face a weird question I don't know how to deal with. I tried to limit the permission of root user to remote login using ssh. So I did the following for a client server, 1. edit /usr/local/etc/sshd_config and modify as below PermitRootLogin forced-commands-only 2. using pubkey... (7 Replies)
Discussion started by: bestard
7 Replies

2. UNIX for Dummies Questions & Answers

How to pass variables into anothother variables?

Below are three variables, which I want to pass into variable RESULT1 username1=userid poihostname1=dellsys.com port1=8080 How can I pass these variables into below code... RESULT1=$((ssh -n username1@poihostname1 time /usr/sfw/bin/wget --user=sam --password=123 -O /dev/null -q... (4 Replies)
Discussion started by: manohar2013
4 Replies

3. Shell Programming and Scripting

Passing awk variables to bash variables

Trying to do so echo "111:222:333" |awk -F: '{system("export TESTO=" $2)}'But it doesn't work (2 Replies)
Discussion started by: urello
2 Replies

4. Shell Programming and Scripting

BASH arrays and variables of variables in C++

Sometimes it is handy to protect long scripts in C++. The following syntax works fine for simple commands: #define SHELLSCRIPT1 "\ #/bin/bash \n\ echo \"hello\" \n\ " int main () { cout <<system(SHELLSCRIPT1); return 0; } Unfortunately for there are problems for: 1d arrays:... (10 Replies)
Discussion started by: frad
10 Replies

5. Shell Programming and Scripting

Running a script with multiple variables like 25 variables.

Hi All, i have a requirement where i have to run a script with at least 25 arguements and position of arguements can also change. the unapropriate way is like below. can we achieve this in more good and precise way?? #!/bin/ksh ##script is sample.ksh age=$1 gender=$2 class=$3 . . .... (3 Replies)
Discussion started by: Lakshman_Gupta
3 Replies

6. Solaris

Solaris 11 + PATH enviroments variables

Ok, this is the little annoying. I can't set up $PATH variable for all non root users on Solaris 11 express. oracle@DevelopBox01:/export/home/oracle$ cat /etc/default/login ........ # PATH sets the initial shell PATH variable #... (6 Replies)
Discussion started by: solaris_user
6 Replies

7. Programming

How to convert byteArray variables to HexaString variables for Linux?

Hello everybody, I am having problem in converting byte array variables to Hexa String variables for Linux. I have done, converting byte array variables to Hexa String variables for Windows but same function doesn't work for linux. Is there any difference in OS ? The code for Windows is given... (2 Replies)
Discussion started by: ritesh_163
2 Replies

8. Shell Programming and Scripting

naming variables with variables

Hello, FIRST QUESTION: I am writing a script in which a query is taken at the beginning of the script to be later used at the end. In the query, variables are generated from a loop, and I would like to assign the variable NAME (not value) with an appended 1, 2, 3, 4.....n. The number of... (2 Replies)
Discussion started by: Allasso
2 Replies

9. UNIX for Dummies Questions & Answers

Where are Oracle variables set in Solaris 5.9

Hi, It is solaris 5.9, and Oracle 10G is the database. If i login as user, and give 'env' command i can see the Oracle environment variables are set. PATH=/usr/bin:/usr/sbin:/usr/lib:/etc/ssh:/opt/oracle/app/oracle/product/10.2.0/db_1/bin:/opt/oracle/crs/oracle/product/10.2.0/crs_1/bin... (1 Reply)
Discussion started by: scriptlearner
1 Replies

10. UNIX for Dummies Questions & Answers

Using Variables to Set Other Variables

I have a script that I'm trying to shorten (below) by removing repetitive code. if ] then commodity_ndm_done=Y fi if ] then customer_ndm_done=Y fi if ] then department_ndm_done=Y fi if ] then division_ndm_done=Y fi (3 Replies)
Discussion started by: superdelic
3 Replies
Login or Register to Ask a Question