LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-23-2010, 12:26 PM   #1
artvarck
LQ Newbie
 
Registered: Feb 2010
Posts: 20

Rep: Reputation: 0
Pass Variable to smbclient


I am trying to pass a variable to smbclient (OS X), but the variable is recognized only as its strict text.

Is there anything syntactically I have to do pass a variable created in the shell (bash) to smbclient (or perhaps any other interactive app)? I've seen references to variables as $[variable] or ${variable} but I've not been able to figure out what works.

Thanks.
 
Old 02-23-2010, 12:47 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 19,252

Rep: Reputation: 4433Reputation: 4433Reputation: 4433Reputation: 4433Reputation: 4433Reputation: 4433Reputation: 4433Reputation: 4433Reputation: 4433Reputation: 4433Reputation: 4433
Quote:
Originally Posted by artvarck View Post
I am trying to pass a variable to smbclient (OS X), but the variable is recognized only as its strict text.

Is there anything syntactically I have to do pass a variable created in the shell (bash) to smbclient (or perhaps any other interactive app)? I've seen references to variables as $[variable] or ${variable} but I've not been able to figure out what works.

Thanks.
Don't know, since you didn't post any of your code. Since we can't see it, don't know what variable you're trying to pass, what it contains, and where it comes from, or what the exact error(s) are that you're getting, we can't really say.

Post your code, but aside from that, I'd try to debug it first, by just echo'ing that variable out to the screen, to see what you're getting. Could be getting truncated, have a special character, etc., that the program is dying on later.
 
Old 02-23-2010, 01:05 PM   #3
artvarck
LQ Newbie
 
Registered: Feb 2010
Posts: 20

Original Poster
Rep: Reputation: 0
Pass Variable to smbclient

Quote:
Originally Posted by TB0ne View Post
Don't know, since you didn't post any of your code. Since we can't see it, don't know what variable you're trying to pass, what it contains, and where it comes from, or what the exact error(s) are that you're getting, we can't really say.

. . . I'd try to debug it first, by just echo'ing that variable out to the screen, to see what you're getting. Could be getting truncated, have a special character, etc., that the program is dying on later.
Let's say I create a variable in bash, thusly:

computer$ todaylog=`date '+%m%d%y'`
computer$ echo $todaylog
computer$ 022310
computer$ touch log.$todaylog
computer$ ls
.
..
log.022310

computer$ smbclient //192.168.1.1 -U user pass
smb:\ > put log.$todaylog
log.$todaylog does not exist
smb:\ >echo $todaylog
echo: command not found
exit
computer$


How do I correctly pass the variable to smbclient?

Thx

Last edited by artvarck; 02-23-2010 at 01:20 PM. Reason: rewording
 
Old 02-23-2010, 01:26 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Once you're running smbclient your bash-constructs become invisible;
you're probably better off to use an smbmount, do your bash-stuff,
and unmount the share again after you're done.
 
Old 02-23-2010, 01:44 PM   #5
HasC
Member
 
Registered: Oct 2009
Location: South America - Paraguay
Distribution: Debian 5 - Slackware 13.1 - Arch - Some others linuxes/*BSDs through KVM and Xen
Posts: 329

Rep: Reputation: 55
Or, using the "-c" parameter of smbclient, this way:
Code:
$ todaylog=`date '+%m%d%y'`
$ touch log.$todaylog
$ smbclient -c "put log.$todaylog" //192.168.1.1 -U user pass
 
1 members found this post helpful.
Old 02-23-2010, 01:49 PM   #6
artvarck
LQ Newbie
 
Registered: Feb 2010
Posts: 20

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by HasC View Post
Or, using the "-c" parameter of smbclient, this way:
Code:
$ todaylog=`date '+%m%d%y'`
$ touch log.$todaylog
$ smbclient -c "put log.$todaylog" //192.168.1.1 -U user pass
That was it! Thank you for your response.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to pass an external variable to awk??? akitty Programming 7 11-13-2008 09:47 AM
pass the variable contain lrios Programming 7 04-18-2008 05:56 PM
pass javascript variable to php ALInux Programming 6 01-06-2006 07:20 AM
How to pass env variable to KDE? koyi Linux - General 0 09-03-2003 04:29 AM
Pass text to variable Zed Linux - Software 6 05-12-2003 04:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration