Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Ok before you flay (or is that fillet) me, we have generated HTML files that our machine shop runs to make kits out of, they essentially put in a number of kits and hit the button and it prints it out.
there is a vbscript on my RHEL server that creates the file needed to print, a cron job then comes by and picks it up and does the rest (printing etc)
part of the script looks like this
Code:
sub WHSBuild(FileName)
Dim fso, tf
a = "\\MYSERVER\Updates\" & FileName & ".kitw"
Set fso = CreateObject("Scripting.FileSystemObject")
Set tf = fso.CreateTextFile(a, True )
i = KITFORM.length - 1
for j = 0 to i step 5
if KITFORM(j).value = FileName then
dim answer
answer=MsgBox("A WHS Picking Report Will Be Generated - Qty: " & KITFORM(j+1).value & (CHR(13)) & (CHR(13)) & " ", 1, FileName)
if answer = 1 then
b = KITFORM(j).value & "," & KITFORM(j+1).value & "," & KITFORM(j+2).value & "," & "LABELS"
tf.writeline(b)
elseif answer = 7 then
b = KITFORM(j).value & "," & KITFORM(j+1).value & "," & KITFORM(j+2).value & "," & "NOLABELS"
tf.writeline(b)
else
b = "CANCEL"
tf.writeline(b)
end if
end if
next
tf.Close
i need to change the owner of the a file from within here to a certain person so the other jobs that run will out put it to the correct printer, i cant find where in VBS i can execute a SUDO CHOWN, but does anyone know if there is a way to execute a bash script from within the VBS file to change the ownership so it comes out in the right place?
No idea how you'd do exactly what you ask, but you indicate there is a cronjob - assuming the script which is being called by the cronjob, could that do the chown? Alternatively could you put a wrapper around the VBS script
Alternatively have you tried approaching the problem from another angle? Is there not a neater way to control which printer the job goes to other than who owns the file? Fixing the problem of the job going to the wrong printer by having a script running a command via sudo seems sort of, well, wrong. I mean for an automated (right?) script to be able to run a command via sudo it has to be able to do so without a password, which means setting up sudo to allow that and so on.
I realise I'm not answering your actual question, but sometimes the best solution to a problem isn't where one first looks for it.
the script is part of a HTML document that they have a short cut to. right now its giving nobody:nobody, on UNIX it used to catch the user login and use that.
the cron job comes around after the file has been created and does further processing.
How about the VBS (which presumably knows the user name that the file should be chowned to) appending that name to the end of the file and the cron job (now a script, if not before) reading that information, stripping it and chowning as required?
BTW how are you running VBS on RHEL? Knowing that might lead to more elegant solutions.
i dont purport to know HOW, althouth all they really are doing is looking to a web page in a directory on RHEL and since all HTML scripting is client side it really isnt running there, just kinda hanging out.
there is a javascript file that generates the web page information in there as well, and then when you put the number in the box and hit the button it calls the function i posted originally. and since the vbs points the text file at RHEL it just writes it there, the directory is a samba share so windows dont see it as anything different or other than another windows shared folder.
the only other thing i can think to do is possibly pass the username via a session variable or something similar.
and the page does not know the linux username, if it did it wouldnt save the files as nobody:nobody
Is the "certain person" always the same one and, if not, on which system (browser client, web server, samba server, ...) is the "certain person" known -- and how is it known?
* You have a RHEL web server
* That webserver has a HTML page which has some VBS scripting on it.
* The VBS script writes to a file on a samba server
Now from your vbs's point of view, it doesn't know that the server you're writing it to is a samba server, all it knows its a Windows share. So can you just treat is at a Windows share and change permissions the same way you would a Windows share?
Since you say all the vbs is client side for any kind of linux commands to work this script would need to run server side or the required commands (ie chown) would need to be available on the client machine thats executing the script.
Alternatively I came across this which is similar in some ways ... http://stackoverflow.com/questions/6...lesystemobject. To get around the fact that fso "it always runs with the credentials of the application using it". It looks messy especially since you have to put in a username / password in the script but that might give you something to work from.
its not a web server, we just create a shortcut to the HTML file on RHEL and it runs locally in IE. (i know i know). Its just a table that gets filled out by the javascript thats there. i know the "name" of the file and the user is the same guy all the time (or could be even if he leaves wouldnt' matter) i just need to chown that text file to user:user rather than nobody:nobody, thought if i could run a bash script and pass it the file name a simple sudo chown user:user $file would work.
HTML file and script files exist in directory directory is samba shared on RHEL box.
user has shortcut to HTML file on RHEL box.
user clicks shortcut to open HTML file on local machine.
user fills in information necessary pushes button on HTML page.
VBS script creates text file and saves it to local RHEL directory.
cron job comes around and prints the necessary forms based on user.
currently file is being saved with nobody:nobody ownership, which appears to be the samba service (which makes sense)
need to have file chown'd by user:user not nobody:nobody so it comes out on the appropriate printers (user is mapped to certain printers in their area).
this has to do with samba and not picking up the user from AD and matching it to a linux user name.
facetwin did this automatically, samba does not. the HTML files are just that HTML form docs that are run from a shortcut to them on the desktop, the VBS that creates the text/other files resides there too, just for consistancy, since all the client machines are windows based, when they click the shortcut it opens the HTML document client side and executes the scripts when they hit the button (again client side).
facetwin (which we had on our old unix box) had an alias file that it would check to write the appropriate user name to the file for the owner, samba does not do this instead it uses nobody, we then do a ls -l > file on the directory and read file in cobol to extract the username and file name then generate the actual doc in cobol and send it along.
so the question becomes how do i get samba to pick up that, there is no samba-alias file to use.
since only one person used this, we simply changed the extension from .txtk to .asyk and then picked that up as a special case in the printing routine, works great and the customer is happy. ultimately simple solution to an otherwise complex problem.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.