The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
grep unix.com with google



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-27-2009
Registered User
 

Join Date: Nov 2009
Location: Stockholm, Sweden
Posts: 4
Is echo $variable >> text.txt working in MacOSX?

Hi

New at this, but want to learn more.

I'm trying this as an Shell Command in MacOSX;


Code:
newdate='<TIME>'
echo $newdate >> /Users/ttadmin/Desktop/test.txt

And it don't work. But if I just use;


Code:
echo <TIME> >> /Users/ttadmin/Desktop/test.txt

(<TIME> is an variable that one program uses.)

Hope someone understand the problem..

Best Regards
Thomas
  #2 (permalink)  
Old 11-27-2009
Neo's Avatar
Neo Neo is online now Forum Staff  
Administrator
 

Join Date: Sep 2000
Location: Asia Pacific
Posts: 7,127
Quote:
Originally Posted by jackt View Post
Is echo $variable >> text.txt working in MacOSX?
Yes, it works fine, but <TIME> is not supported, I don't think. Try date instead.



Code:
newdate=$(date)
echo $newdate >> /Users/ttadmin/Desktop/test.txt

  #3 (permalink)  
Old 11-27-2009
Registered User
 

Join Date: Nov 2009
Location: Stockholm, Sweden
Posts: 4
Thanks for quick replay, but that don't work either.


Code:
newdate='example'
echo $newdate >> /Users/ttadmin/Desktop/test.txt

This for example just give me one blank file (test.txt).

(The <DATE> is an variable that the app I try to use sends out. Other is for example <FILE>, <USER> and so on..)
  #4 (permalink)  
Old 11-27-2009
Neo's Avatar
Neo Neo is online now Forum Staff  
Administrator
 

Join Date: Sep 2000
Location: Asia Pacific
Posts: 7,127
Quote:
Originally Posted by jackt View Post
Thanks for quick replay, but that don't work either.
Works fine for me on my Mac


Code:
apple:/ neo$ 
apple:/ neo$ newdate=$(date)
apple:/ neo$ echo $newdate >> text.txt                       
apple:/ neo$ cat text.txt
Fri Nov 27 17:59:40 ICT 2009
apple:/ neo$

  #5 (permalink)  
Old 11-27-2009
Registered User
 

Join Date: Nov 2009
Location: Stockholm, Sweden
Posts: 4


Ok. It works in the Terminal for me to..

But not inside the application..

The app is the FTP-server Rumpus (one Mac-only app).

(see attached picture)
Attached Thumbnails
echo-variable-text-txt-working-macosx-picture-2.png  
Bits Awarded / Charged to jackt for this Post
Date User Comment Amount
11-27-2009 Neo Post facts in the first post, not the last! -10,000
  #6 (permalink)  
Old 11-27-2009
Neo's Avatar
Neo Neo is online now Forum Staff  
Administrator
 

Join Date: Sep 2000
Location: Asia Pacific
Posts: 7,127
Quote:
Originally Posted by jackt View Post


Ok. It works in the Terminal for me to..

But not inside the application..

The app is the FTP-server Rumpus (one Mac-only app).

(see attached picture)
Of course it does not work. You cannot run Bash terminal commands like this inside an FTP FUI client.

Why did you not mention this in your first post?? Please post all the details in when post a question. Thanks.

Last edited by Neo; 11-27-2009 at 08:27 AM.. Reason: Reopened thread.
  #7 (permalink)  
Old 11-27-2009
Registered User
 

Join Date: Nov 2009
Location: Stockholm, Sweden
Posts: 4
I'm sorry, of course should I get you all every info I have..

Backstory: In the FTP-Server (Rumpus) you can use 'Event Notice' that triggers when someone downloads or uploads some files.

And one thing is to use Shell Commands like this (this put the file in a folder that is named after an variable and put some variables in an xml-file in the same folder);


Code:
mkdir /<HOMEPATH ANONYMOUS>/<FORMVAR kund>
echo '<?xml version="1.0" encoding="ISO-8859-1"?>' >> /<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>.xml
echo '<data>' >> /<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>.xml
echo '\t<kund><FORMVAR kund></kund>' >> /<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>.xml
echo '\t<kundmail><FORMVAR kundmail></kundmail>' >> /<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>.xml
echo '\t<projektledare><FORMVAR projektledare></projektledare>' >> /<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>.xml
echo '\t<filename_arg><FILENAME></filename_arg>' >> /<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>.xml
echo '\t<sidor><FORMVAR sidor></sidor>' >> /<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>.xml
echo '\t<date_arg><DATE></date_arg>' >> /<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>.xml
echo '</data>' >> /<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>.xml
cp <FILE> /<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>
rm <FILE>

This works perfect, but is somehow a bit difficult to overlook and the application don't like this amount of code (to many characters). And I get some input from a friend to use the "$example" to get some better code;


Code:
mkdir /<HOMEPATH ANONYMOUS>/<FORMVAR kund>
outputfile = '/<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>.xml'
echo '<?xml version="1.0" encoding="ISO-8859-1"?>' >> $outputfile
echo '<data>' >> $outputfile
echo '\t<kund><FORMVAR kund></kund>' >> $outputfile
echo '\t<kundmail><FORMVAR kundmail></kundmail>' >> $outputfile
echo '\t<projektledare><FORMVAR projektledare></projektledare>' >> $outputfile
echo '\t<filename_arg><FILENAME></filename_arg>' >> $outputfile
echo '\t<papperkv><FORMVAR papperkv></papperkv>' >> $outputfile
echo '\t<sidor><FORMVAR sidor></sidor>' >> $outputfile
echo '\t<format><FORMVAR format></format>' >> $outputfile
echo '\t<date_arg><DATE></date_arg>' >> $outputfile
echo '\t<time_arg><TIME></time_arg>' >> $outputfile
echo '\t<note><FORMVAR note></note>' >> $outputfile
echo '</data>' >> $outputfile
cp <FILE> /<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>
rm <FILE>

But this don't work, and it is possible like that Neo is saying that "outputfile = '/<HOMEPATH ANONYMOUS>/<FORMVAR kund>/<FILENAME>.xml'" don't work inside applications (in MacOS X).

So my question this time is:
Is there some other way to solve this? It feels like the app just use direct commands (like the first example).

Thanks Neo for the info, and sorry that I missed all extra info..

Best Regards..
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Echo Variables and Text Grizzly Shell Programming and Scripting 3 10-04-2009 04:49 PM
Echo working funny hemtar Shell Programming and Scripting 8 06-23-2009 11:24 AM
calling a variable to echo to a log luma Shell Programming and Scripting 1 08-17-2007 11:30 PM
assigning variable value using echo shellburger Shell Programming and Scripting 2 07-11-2005 12:52 PM
Display from a variable using echo. jagannatha UNIX for Dummies Questions & Answers 4 06-12-2003 04:38 PM



All times are GMT -4. The time now is 02:21 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0