Results 1 to 3 of 3
Hi,
for a daily server audit script, I'm sending the log file to a central offsite server.
To do this, I'm using
su user1 -c 'scp myfile.log remoteuser1@remoteserver:/home/remoteuser1/Documents/logs'
This works ...
- 08-24-2007 #1Just Joined!
- Join Date
- Aug 2005
- Posts
- 99
Include variable in quoted command set
Hi,
for a daily server audit script, I'm sending the log file to a central offsite server.
To do this, I'm using
su user1 -c 'scp myfile.log remoteuser1@remoteserver:/home/remoteuser1/Documents/logs'
This works fine.
However, I would like to include a variable between the quotes. That's where it fails.
For example
su user1 -c 'scp $MYFILE remoteuser1@remoteserver:/home/remoteuser1/Documents/logs'
gives a usage echo for scp
Is there a workaround for this?
I have to su as a different user for authentication purposes.
Marinus.
- 08-24-2007 #2Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
Hi,
Single quotes prevent the shell to expand the variable, try double quotes:
RegardsCode:su user1 -c "scp $MYFILE remoteuser1@remoteserver:/home/remoteuser1/Documents/logs"
- 08-24-2007 #3Just Joined!
- Join Date
- Aug 2005
- Posts
- 99
Hello Franklin,
that you very much. That was it.
Marinus.


Reply With Quote